1 / 24

Ubiquitous Computing Practice ( Photo Resistor )

Ubiquitous Computing Practice ( Photo Resistor ). Youn-Hee Han, In- Seok Kang { yhhan , Iseka }@kut.ac.kr Laboratory of Intelligent Networks Advanced Technology Research Center Korea University of Technology http://link.kut.ac.kr. Contents. Introduction PhotoResistor LED 밝기 조절

galen
Télécharger la présentation

Ubiquitous Computing Practice ( Photo Resistor )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ubiquitous Computing Practice(Photo Resistor) Youn-Hee Han, In-Seok Kang {yhhan, Iseka}@kut.ac.kr Laboratory of Intelligent NetworksAdvanced Technology Research CenterKorea University of Technology http://link.kut.ac.kr

  2. Contents • Introduction • PhotoResistor • LED 밝기 조절 • Processing를 이용한 Graph

  3. Introduction • PhotoResistor (Cadmium sulfide or Light dependent resistor) • 빛의 세기에 따라 저항 값이 변하는 센서이다

  4. Introduction

  5. Introduction http://www.ladyada.net/learn/sensors/cds.html

  6. Introduction

  7. Introduction

  8. Photo resistor

  9. Photo resistor

  10. schematic

  11. Result

  12. Reference • Functions • analogRead(pin) – analog pin 에서 int(0~1023) 반환 • analogWrite(pin, val) – val(0~255) 값출력 • Serial • begin(baud) – bits per second • ex)9600, 19200.. • print(val) – 시리얼 통신 이용 val출력 • Serial.print(78) gives "78" • print(val, format) – val을 원하는 format에 맞춰 출력 • Serial.print(78, BIN) gives "1001110"

  13. Reference • Math • map(value, fromLow, fromHigh, toLow, toHigh) • Value 현재 값의 범위 fromLow ~ fromHigh • 변경하고 싶은 값의 범위 toLow, toHigh • ex) intval = analogRead(0); val= map(val, 0, 1023, 0, 255); • constrain(inputVal, lowRange, highRange) • inputVal값이 lowRange ~ highRange사이의 값이면 inputVal반환 • inputVal값이 lowRange값 보다 작으면 lowRange값 반환 • inputVal값이 highRange값 보다 크면 highRange값 반환

  14. 센서의 analog값 출력 Sketch intphotocellPin = 0; intphotocellReading; void setup(void) { Serial.begin(9600);// bit per second. } void loop(void) { photocellReading= analogRead(photocellPin); Serial.print("Analog reading = "); Serial.println(photocellReading); delay(1000); }

  15. LED 밝기 조절

  16. LED 밝기 조절

  17. schematic

  18. LED 밝기 조절 Sketch intlightPin = 0; intledPin = 11; void setup() {pinMode(ledPin, OUTPUT); } void loop() {intlightLevel = analogRead(lightPin); lightLevel = 1023 – lightLevel;lightLevel = map(lightLevel, 0, 1023, 0, 255); lightLevel = constrain(lightLevel, 0, 255);analogWrite(ledPin, lightLevel); }

  19. Processing 을 이용하여 Graph를 출력하기 Processing를 이용한 Graph

  20. Arduino board

  21. Arduino - Sketch intlightPin = 0; void setup() { Serial.begin(9600); } void loop() { Serial.println(analogRead(lightPin)); delay(100); }

  22. Processing - Sketch import processing.serial.*; Serial myPort; // The serial port intxPos = 1; // horizontal position of the graph void setup () { size(400, 300); println(Serial.list()); myPort = new Serial(this, Serial.list()[1], 9600); myPort.bufferUntil('\n'); background(0); } void draw () { }

  23. Processing - Sketch void serialEvent (Serial myPort) { String inString = myPort.readStringUntil('\n'); if (inString != null) { inString = trim(inString); float inByte = float(inString); inByte = map(inByte, 0, 1023, 0, height); stroke(127,34,255); line(xPos, height, xPos, height - inByte); if (xPos >= width) { xPos = 0; background(0); } else { xPos++; } } }

  24. Result

More Related