LED Sensors


Parts of the Arduino UNO

An LED attached to number 13, which behaves differently from the other outputs.

The clock sets the speed of the board measured in megahertz.

The reset button to reboot the board.

The microcontroller used to store information and can be removed to use separately.

The power supply does not require to be plugged in for the board to be used.

Software required is called Arduino IDE

Everything on this IDE is written on a loop.




void setup() - in this is where parameters are set for the digital pins telling them what they are if inputs or outputs and how fast they are communicating * with different speeds

most variables within the arudino code are best used globally as it can be used with every function created.

In this we will use Blink instead of Hello World to retrieve an output signal. The file is found in File > Examples > 1. Basics > Blink.




Within the above BLINK code it is translated as follows;

  • LED_BUILTIN = PIN 13 (on the Arduino UNO Board)
  • HIGH = 5 Volts
  • LOW = 3 Volts
  • delay (1000); = 1 second delay (recorded in milliseconds)
To upload this code to the board you will need the following;
  • UNO R3
  • USB Cable
Once the board is connected to the PC you will need to ensure your board and serial port are selected with Arduino UNO otherwise the upload will not work. To ensure it is done select Tools > BoardArduino Uno and then ToolsPort, there your port should have Arduino Uno if the device is plugged into the PC. Uploading the code from the IDE you will need to click the right arrow shown below, the upload will be successful once the bottom of the window states "Done Uploading". On the Uno board once the code is uploaded the L, TX and RX will light up and blink fast until it flash one per second.


To externally control the speed of the blinks we will need to follow materials to be connected to the board;

  • Potentiometer
  • 3 BreadBoard Jumper Wires
  • Breadboard
The code to create this is called the AnalogReadSerial, it is found in File > Examples > 1. Basics > AnalogReadSerial.





Black wire = Ground (GND)
White wire = Output (A0)
Red wire = Power (5V)

After setting up the above images followed by uploading the code, then the L, TX and RX will blink fast and you can control the speed of the light from the potentiometer as seen in the video below.



The dialling of the potentiometer can be seen through the serial monitor in the top right corner of the IDE window.




 
This is when the potentiometer is turned to Low (ground)

This is when the potentiometer is turned to the Middle (output)

This is when the potentiometer is turned to High (power)



The above code is the combination of Blink and AnalogReadSerial to create "Blinkspeed" which controls the speed of the LED with the potentiometer. If serial monitor is opened at the same time you can also see the numbers as it increases and decreasing with each turn.


Replacing the potentiometer with LDRs (light dependent resistors) you will need a 10K Resistor and a Photoresistor. 



As you move your hand over the sensors it will either increase or decrease the speed of the flashes. The video below demonstrates how they act.
 






Footnote
Potentiometer (2017) Available at: https://components101.com/resistors/potentiometer (Accessed: 11 October 2023).






Comments

Popular posts from this blog

Multi-Sensor Health Monitor - Arduino Project

Sensors and Actuators cont'd

Recommender System