Adjustable Frequency of LED Using an Arduino

by jadenrbiron in Circuits > Arduino

156 Views, 2 Favorites, 0 Comments

Adjustable Frequency of LED Using an Arduino

FZE86HKM0MFW6E4.png

Created an adjustable LED in my mechatronics class that utilizes an Arduino.

Supplies

WIN_20240829_11_40_00_Pro.jpg
  1. 1 LED
  2. 1 Potentiometer (POT)
  3. 6 jumper wires (The wires that can connect to a breadboard)
  4. breadboard
  5. Arduino
  6. 1 100 Ohm Resistor
  7. USB type B wire
  8. Computer (one that could support Arduino IDE)

How to Assemble

Screenshot (4).png
Screenshot (1).png
  1. Have 1 wire be connected to the ground of the Arduino to be connected to the ground (negative) of the breadboard
  2. Add have 1 wire be connected to the 5V port on the Arduino and the other side of the wire to be connected to the positive of the Breadboard.
  3. Put in your LED onto the breadboard
  4. Put in your 100 Ohm resistor into the ground of the breadboard and the anode (negative) of the LED which is the shorter side of the LED
  5. Connect 1 wire to a numbered pin in the Arduino and have it connect to the positive of the LED (the longer side).
  6. Put your potentiometer into the Breadboard
  7. Have 1 wire be attached to the positive on the bottom of the breadboard and the right pin of the Potentiometer
  8. Have another wire be attached to the negative on the bottom of the breadboard and the left pin of the Potentiometer.
  9. Have one wire be connected to an analog port of the Arduino and the middle pin of the potentiometer.

How to Code the Arduino

  1. Open up the Arduino IDE application on a computer that supports it (chromebook doesn't support Arduino IDE)
  2. First, before the void setup option, you have to define your pins that you're using to power the circuit
  3. int sensorValue = 0; 
  4. typeint sensorPin = A0;
  5. int ledPin = 13;
  6. Now that you're finished with that, go to void setup and type;  pinMode(ledPin, OUTPUT);
  7. Now, in void loop, type :
  8.  sensorValue = analogRead(sensorPin);
  9.  // turn the ledPin on
  10.  digitalWrite(ledPin, HIGH);
  11.  // stop the program for <sensorValue> milliseconds:
  12.  delay(sensorValue);
  13.  // turn the ledPin off:
  14.  digitalWrite(ledPin, LOW);
  15.  // stop the program for <sensorValue> milliseconds:
  16.  delay(sensorValue);
  17. Now the code of the Arduino should work and you should be able to adjust the frequency of the blinking of the LED's.

References

Screenshot (1).png
FZE86HKM0MFW6E4.png

This project is from my Mechatronics 1 class taught by Mr. Sweet.