Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- MTI HW4 Part 2 -
- */
- const int lightSensorPin = A1;
- const int ledPin = 9;
- int inValue; //0~1023
- int outValue;//0~255
- void setup(){
- pinMode(lightSensorPin, INPUT);
- pinMode(ledPin, OUTPUT);
- Serial.begin(9600);
- }
- void loop(){
- inValue = analogRead(lightSensorPin);
- outValue = int(inValue)*0.249; // 0.249 = 255/1023
- analogWrite(ledPin, outValue);
- // Serial.println(outValue);
- // Serial.println(inValue);
- // Serial.println();
- // delay(500);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement