Arduino - Sensor Light With and Led

5,805

22

1

Introduction: Arduino - Sensor Light With and Led

int led = 13;
void setup() {

  Serial.begin(9600);
  pinMode (led,OUTPUT);
}


void loop() {

  int sensorValue = analogRead(A0);
  float voltage = sensorValue * (5.0 / 1023.0);
  Serial.print("Valore: ");
  Serial.println(voltage);
  delay (400);

  if (voltage > 2.00); Serial.println ("Led Spento");
  if (voltage > 2.00); digitalWrite (led,LOW);

  if (voltage < 1.80)  Serial.println ("Led Acceso");
  if (voltage < 1.80)  digitalWrite (led,HIGH);


}

Be the First to Share

    Recommendations

    • Puzzles Speed Challenge

      Puzzles Speed Challenge
    • "Can't Touch This" Family Contest

      "Can't Touch This" Family Contest
    • CNC Contest 2020

      CNC Contest 2020

    Discussions

    0
    jenniferm8
    jenniferm8

    5 years ago on Introduction

    I am trying to set up multiple light sensors that will trigger sound. I'm using both arduino and processing.. Does anyone know what I should put into y code to allow this to happen? The bit that sorta says "if light sensor 1 reads value 0, trigger sound1'. I've tried this multiple times but doing it with more than one sensor doesn't seem to work. Hope someone can help or direct me where else to look!