Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const int photoPin=A0;
- int photoValue=0;
- int lightVal=0;
- void setup()
- {
- // put your setup code here, to run once:
- Serial.begin(9600);
- pinMode(photoPin, INPUT);
- }
- void loop()
- {
- // put your main code here, to run repeatedly:
- photoValue=analogRead (photoPin);
- lightVal=map (photoValue, 0, 907, 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