[go: up one dir, main page]

0% found this document useful (0 votes)
35 views1 page

Arduino Tecno

This Arduino program reads a light sensor and controls an LED based on the sensor's value. If the sensor detects light, it turns on the LED and plays a series of tones; otherwise, it turns off the LED. The program initializes the necessary pins and outputs messages to the serial monitor for debugging.

Uploaded by

M Lafuente
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views1 page

Arduino Tecno

This Arduino program reads a light sensor and controls an LED based on the sensor's value. If the sensor detects light, it turns on the LED and plays a series of tones; otherwise, it turns off the LED. The program initializes the necessary pins and outputs messages to the serial monitor for debugging.

Uploaded by

M Lafuente
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

int sensorValue;

const int ledPin = 7;


const int sensorLuz = 3;

void setup ()
{
pinMode (ledPin, OUTPUT);
pinMode (sensorLuz, INPUT);
Serial.begin(9600);
Serial.println("comienza el programa");
pinMode (9, OUTPUT) ;
}

void loop ()
{

sensorValue = digitalRead(sensorLuz);
Serial.println("E sensor esta a ");
Serial.println(sensorValue);

if (sensorValue == 1)
{
digitalWrite(ledPin, HIGH);
Serial.println("enciendo el led");
tone(9, 392,400);
delay(400);
tone(9, 102,400);
delay(400);
tone(9, 245,400);
delay(400);
tone(9, 342,400);
delay(400);
}
else
{
digitalWrite(ledPin, LOW);
digitalWrite(9, HIGH);
Serial.println("apago el led");

Arduino:1.8.19 (Windows Store 1.8.57.0) (Windows 10), Tarjeta:"Arduino Mega or Mega


2560, ATmega2560 (Mega 2560)"

You might also like