lorenzo_cesaretti

Fotoresistenza Arduino

Apr 13th, 2021
711
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int analogInPin = A0;
  2. int sensorValue = 0;
  3. int ledR = 5;
  4. int ledV = 3;
  5.  
  6. void setup() {
  7.   Serial.begin(9600);
  8.   pinMode( analogInPin, INPUT);
  9.   pinMode (ledR, OUTPUT);
  10.   pinMode (ledV, OUTPUT);
  11. }
  12.  
  13. void loop() {
  14.   sensorValue = analogRead(analogInPin);  
  15.   if (sensorValue<200){
  16.     digitalWrite (ledV,HIGH);          
  17.   }
  18.   else{
  19.     digitalWrite (ledV,LOW);
  20.   }
  21.   if (sensorValue>700){
  22.     digitalWrite (ledR,HIGH);
  23.   }
  24.   else{
  25.     digitalWrite (ledR,LOW);
  26.   }
  27.  
  28.   Serial.print("sensor = " );
  29.   Serial.println(sensorValue);      
  30.  
  31.   delay(1000);
  32. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×