Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *Divya Inaganti
- *June 14, 2017
- *How to use a photo resistor activity
- */
- const int photoPin= A0 ;
- int photoValue = 0;
- int lightVal= 0;
- void setup()
- {
- Serial.begin (9600);
- pinMode(photoPin, INPUT);
- }
- void loop()
- {
- photoValue= analogRead (photoPin);
- lightVal= map(photoValue, 0, 1020, 255, 0);
- lightVal= constrain(lightVal, 0, 255);
- Serial.print ("Photoresistor value = ");
- Serial.print(photoValue);
- Serial.print ("lightVal = ");
- Serial.println(lightVal);
- delay(100);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement