ARDUINO PROGRAMMING
Hello! For this week’s blog, we will be focusing on ARDUINO PROGRAMMING!🎮🖥 I had so much fun doing this lesson and this blog will be documenting the different codes we learnt. Along with the Arduino Programming, we will also be using the Maker UNO board, I will be documenting the experience with videos and photos too. Let’s begin!
This is a link to the Arduino 4 challenges documentation: https://docs.google.com/document/d/1ACngzrPfGAoOpsvWMa6rMBsNS5O0Ha_4di-aPHfa4Xw/edit
INDIVIDUAL ASSIGNMENT
In this individual assessment, we were tasked to complete multiple tasks using the TINKERCAD software. It is basically a simulation software that allows us to build the our Arduino Uno board and run the codes. We were tasked with 4 challenges and I will be documenting them below.
- INPUT DEVICES
- Interface a Potentiometer Analog Input to the Maker Uno board and measure its signal in serial monitor Arduino IDE
Description of set-up:
Red Wires - Connected to ‘5V’ pin and and the anode of the breadboard, followed by connecting it to the potentiometer. Another set of red wires are connected to the two other anodes of the breadboard.
Black Wires - Connected to the ‘GND; pin and the cathode of the breadboard, followed by connecting it to the potentiometer. Another set are then connected to the two other cathodes of the breadboard.
Green Wires - Connected to ‘A0’ pin followed by connecting it to the potentiometer.
Yellow Wires - Connected to pin ‘13’ followed by the anode side of the LED beside the resistor.
Coding set-up:
Below is an image of the block code:
Description of set-up:
This is the base code in order for the LED to blink and be controlled by the potentiometer. However, this code does not include measuring its signal in the serial monitor Arduino IDE. Hence, I have modified the code to change the setting.
Original Code:
// C++ code
//
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0);
// turn the LED on
digitalWrite(LED_BUILTIN, HIGH);
// pause the program for <sensorValue> milliseconds
delay(sensorValue); // Wait for sensorValue millisecond(s)
// turn the LED off
digitalWrite(LED_BUILTIN, LOW);
// pause the program for <sensorValue> milliseconds
delay(sensorValue); // Wait for sensorValue millisecond(s)
}
Modified (Highlighted parts):
// C++ code
//
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(9600);
}
void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0);
Serial.println(sensorValue);
// reading sensorValue
// turn the LED on
digitalWrite(LED_BUILTIN, HIGH);
// pause the program for <sensorValue> millseconds
delay(sensorValue); // Wait for sensorValue millisecond(s)
// turn the LED off
digitalWrite(LED_BUILTIN, LOW);
// pause the program for <sensorValue> millseconds
delay(sensorValue); // Wait for sensorValue millisecond(s)
}
Final Outcome:
Below will be a video of running a simulation of the above set-up with serial monitor:
- Interface a LDR to Maker Uno board and measure its signal in serial monitor Arduino IDE
Description of set-up:
Red Wires - Connected to ‘5V’ pin to the cathode of the breadboard. Followed by another wire connected from the cathode of the motherboard to the LDR.
Black Wires - Connected to the ‘GND’ pin to the anode of the breadboard.
Yellow Wires - Connected from pin ‘9’ to the anode side of the LED beside the resistor.
Green Wires - Connected from ‘A0’ pin to the LDR, the same side of the LDR as the other resistor.
Coding set-up:
Below is an image of the text code in TINKERCAD:
Description of set-up:
This code fulfills the requirement of having a LDR able to control the brightness of the light and also monitor the signal value using the serial monitor.
Original Code:
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(9, OUTPUT);
}
void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0);
// print the sensor reading so you know its range
Serial.println(sensorValue);
// map the sensor reading to a range for the LED
analogWrite(9, map(sensorValue, 0, 1023, 0, 255));
delay(100); // Wait for 100 millisecond(s)
}
Final Outcome:
Below will be a video of running a simulation of the above set-up:
2. OUTPUT DEVICES
- Interface 3 LEDs (Red, Yellow, Green) to maker Uno and program it to perform something.
// C++ code
//
void setup()
{
pinMode(8, OUTPUT);
pinMode(3, OUTPUT);
pinMode(2, OUTPUT);
}
void loop()
{
digitalWrite(8, HIGH);
digitalWrite(3, LOW);
digitalWrite(2, LOW);
delay(2000); // Wait for 2000 millisecond(s)
digitalWrite(8, LOW);
digitalWrite(3, HIGH);
digitalWrite(2, LOW);
delay(2000); // Wait for 2000 millisecond(s)
digitalWrite(8, LOW);
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
delay(2000); // Wait for 2000 millisecond(s)
}
Final Outcome:
Below will be a video of running a simulation of the above set-up:
Link to simulation: https://www.tinkercad.com/things/9zYbUwHSv2p-funky-blorr/editel?sharecode=_2iZ_IRPw5arZTX3RfCAfk-0cbc89TZlwbM3LaF2CiY
Here is a video of using the software on the Maker Uno Board:
- Interface the DC motor to the maker Uno board and program it to on and off using push button on board.
Link to simulation: https://www.tinkercad.com/things/jZfrfkkPKQN-copy-of-example-8-controlling-dc-motor-with-push-buttons/editel?sharecode=5rEMfihwhj7SVEyoEkv7nbiwBqQ-Bp2ePyhk2IJdQGM
Comments
Post a Comment