LED Lights
The hardware required are:
-Arduino Board
-Bread Board
-LED
-USB Cable
-10k ohm Resistor
-220 ohm Resistor
-The led light with basic code
Red wire from bread board to 5V, Black wire from bread board to Ground GND and White wire from bread board to Analog input A0.
Also, insert the LED light in GND and 13V.
Then from the basic code AnalogReadSerial:
// the setup routine runs once when you press reset:
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(SensorValue); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(sensorValue); // wait for a second
}
Lastly after running the code and connecting the wires, the outcome is:
Also, you can change the speed of light by covering or without covering your hands.





Comments
Post a Comment