Arduino Programming
Week 6 π
This week, we had our Arduino Programming practical.
Based on the experiences that we had and the knowledge that we gained during the practical and the competency test, we have to program some programs using tinkercad and also using Arduino Uno.
For the input devices, the first would be interfacing the Potential Analog Input maker.
I first used tinkercad for a simulation.
π¬ Firstly, I opened a new circuit, then placed an Arduino Uno and also a breadboard.
π¬ Next is to place the other components on the circuit and the breadboard.
URL Link:
https://www.tinkercad.com/things/7KYRIhIEXeN
For the Arduino Uno, this is the code that I used:
// 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 LED on
digitalWrite(LED_BUILTIN, HIGH);
delay(sensorValue); // Wait for sensorValue millisecond(s)
// turn LED off
digitalWrite(LED_BUILTIN, LOW);
delay(sensorValue); // Wait for sensorValue millisecond(s)
}
πA picture of the circuit:
πVideo of how it works:
The second would be to interface an LDR to maker uno.
Firstly, it would be the simulation on thinkercad.
π¬ First, it is to place an Arduino Uno board and a breadboard.
π¬ Next is to place the other components on the Arduino Uno and the breadboard.
URL Link:
https://www.tinkercad.com/things/6Nq2t2dgFJY
For the Arduino Uno, this is the code I used:
// C++ code
//
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop()
{
sensorValue = analogRead(A0);
Serial.println(sensorValue);
analogWrite(13,map(sensorValue, 0, 1023, 0, 255));
delay(1000);
}
πVideo:
For the output devices, the first is to interface would be the LEDs.
I first used Thinkercad to program the LEDs to blink on and off in a pattern.
π¬ Firstly, I opened a new circuit, then placed an Arduino Uno and also a breadboard.
π¬ Next is to place the other components on the circuit and the breadboard.
URL Link for Thinkercad:
https://www.tinkercad.com/things/9NVa2Ejgm42
However, for the Arduino Uno, I programmed it to turn on one at a time before turning it off one at a time.
This is the code I used for the Arduino Uno:
void setup() {
// put your setup code here, to run once:
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(11, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(12, HIGH);
delay(1000);
digitalWrite(11, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
digitalWrite(12, LOW);
delay(1000);
digitalWrite(11, LOW);
delay(1000);
}
π A photo of how it looks:
π A video of how it works:
Next was to program the DC motor with a programmable button.
Firstly is to create the simulation on Tinkercad.
π¬ Firstly, it is to open a new circuit, the to place an Arduino Board and a breadboard.
π¬ Next, it is to add all the other components
This one is the most challenging one among all of the other ones as I had to do more research on how to do it.
URL Link:
π§ πReflection:
From these experiences, I learnt that Arduino programming is not easy, especially if you are not able to upload the code due to some error or that you are not able to get what you want to work on the board after trying many times. However, after these experiences, I feel that I would be able to be more proficient as I am able to learn from the mistakes that I made, and what can be done differently to improve and also reduce the time taken to do the program and that it would be helpful in the future for our final year project.
References:
Youtube.com. 2021. [online] Available at: <https://www.youtube.com/watch?v=e1FVSpkw6q4> [Accessed 4 December 2021].
Youtube.com. 2021. [online] Available at: <https://www.youtube.com/watch?v=MojSo7OtF9w> [Accessed 6 December 2021].
Youtube.com. 2021. [online] Available at: <https://www.youtube.com/watch?v=qvBiVrvc8p8> [Accessed 6 December 2021].
Comments
Post a Comment