document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2. MTI HW4 Part 2 -
  3. */
  4.  
  5. const int lightSensorPin = A1;
  6. const int ledPin = 9;
  7. int inValue; //0~1023
  8. int outValue;//0~255
  9.  
  10. void setup(){
  11. pinMode(lightSensorPin, INPUT);
  12. pinMode(ledPin, OUTPUT);
  13.  
  14. Serial.begin(9600);
  15. }
  16.  
  17. void loop(){
  18. inValue = analogRead(lightSensorPin);
  19. outValue = int(inValue)*0.249; // 0.249 = 255/1023
  20.  
  21. analogWrite(ledPin, outValue);
  22.  
  23. // Serial.println(outValue);
  24. // Serial.println(inValue);
  25. // Serial.println();
  26. // delay(500);
  27.  
  28.  
  29. }
');