Blog 2: Arduino Programming💻
- Nov 24, 2024
- 4 min read
Updated: Jan 31, 2025
YIPEEE, WIX FORMATTING WORKS AGAINN, LET US BEGIN!!

Hi!
Welcome back to another blog👋🏼
This might take longer than usual,
so just sit back and relax🍿
For this blog, I have 2 tasks to describe
& there's a bit more at the end later👀
Moving on👇🏼
Task 1: Input devices
For this first task, I chose to do (a)
"a. Interface a potentiometer analog input to Maker UNO board and measure/show its signal in serial monitor Arduino IDE."

What is a potentiometer?🤔
A type of variable resistor with adjustable resistance Ω
(by turning the knob🔁)
For the code, I used this as a reference
Code | How it works |
void setup() {Serial.begin(9600); pinMode(13,OUTPUT);} void loop() {Serial.println(analogRead(A0)); delay(100); digitalWrite(13, HIGH); delay(analogRead(A0)); digitalWrite(13, LOW); delay(analogRead(A0));} |
|
To summarize😅:
When the potentiometer is turned, an analog signal is sent to A0 and the serial monitor displays a value of 0 to 164. Then, the LED connected to pin 13 blinks in intervals of 0 to 164ms🚨
*this is the code without the LED:
void setup()
{Serial.begin(9600);}
void loop()
{Serial.println(analogRead(A0));
delay(100);}
Here's a video of the simulation🔊:
You could also connect the potentiometer directly to the Arduino, but the Maker UNO kit does not have male to female dupont wires, so I included a breadboard in the simulation🤓
Next up, Task 2!👇🏼
Task 2: Output devices

This time, I had to:
"Interface 3 LEDs (Red, Yellow, Green) to Maker UNO board and program it to perform an action (fade or flash, etc). Use the pushbutton on the Maker UNO board to start/ stop the action."
...Why did I choose to make the LEDs fade
this took way too long..
below is the code
Code | How it works |
int brightness = 0; int fadeAmount = 5; void setup() {pinMode(2, INPUT_PULLUP); pinMode(3, OUTPUT);} void loop() {if (digitalRead(2) == LOW) {analogWrite(3, brightness); brightness = brightness + fadeAmount; if (brightness <= 0 || brightness >= 255) fadeAmount = -fadeAmount;} else {analogWrite(3, brightness);} delay(100);} |
|
At first I thought the code was fine, but when I ran the simulation, the LEDs started fading in and out and they only stop when the button is pressed, instead of the other way round😤😤
Now I have no clue...
I keep changing the program but this is the best I could get,
and it works, so I won't complain
Anyways, here's the 2nd video😴:
Luckily, Tinkercad has tutorials for how to use the circuits (e.g. Multiple LEDs & Breadboards) which helped a lot with this task🙌🏼 For example, if you want to fade an LED, it has to be connected to the Pulse Width Modulation (PWM) digital pins.
Here is a video of how PWM works:
on a side note, about halfway through,
I realized I had access to Tinkercad this whole time...
I could have used it for modelling the car in ICPD🤦🏼♂️

it's okay🥲 got more practice with Fusion360🔥
Weeeee, another learning reflection🙃
Learning Reflection
You know sometimes,
even AI cannot help with your code,
then you know you're cooked
Jokes aside,
I feel like I learned a lot about programming from making this blog..
right now my vision is blurry from staring at my laptop for so long💀 (it's 12 midnight🌙 on 24/11)
After trying to understand how the program for Task 2 works,
hours of just messing with the code(+ video editing), I'm still not 100% sure why it works that way😭
Anyways, at least I got to learn about what each of the lines do, as I read the code over and over again😂 I definitely still have more to learn, especially since our group's CA1 project will need use the Arduino🥲
Now that I have access to Tinkercad, I can explore more features using the circuit simulations there, maybe learn how to program other things💻🤔
..and I will definitely be trying out the 3D modelling, it looks like a simpler version of Fusion 360, since it uses basic shapes mostly🔴🟦
...
oh wait, there's more..
can't forget about Practical 2!
Practical 2: Arduino Programming
First of all, I'd like you to meet "Shelly the Shark"
(from this ICPD practical)


Yea her jaw is still🫤🫤
We also had to make a part move using the servo motor🤔
and thanks to Muhsin our programmer, our Arduino had 3 functions:
The servo & LEDs move and blink to the music🤯🤯🤯
Here you can see our "final product", as well as other groups'

Sadly, I forgot to take a video of the LEDs + music + servo working☹️
Still,
Shelly's mouth was able to open,
but it couldn't close back😭
I think trying to make the jaw move was too hard,
(the servo kept disconnecting from the jaw)
maybe the tail or fin would have been easier to do😅
but overall this practical was still fun,
got to use cardboard again, to make the "base" for the shark,
and seeing the other groups' final products🤩
more moments from the practical here👈🏼
...
okay now it's done..
whyareyoustillscrolling

..alright bye for now👋🏼

References:
www.tinkercad.com. (n.d.). Learn how to use Tinkercad. [online] Available at: https://www.tinkercad.com/learn
www.youtube.com. (n.d.). How Does PWM Work? [online] Available at: https://www.youtube.com/shorts/aeE0u1J-1pg
Other useful videos:
www.youtube.com. (2018). Fading LED With Arduino in Tinkercad. [online] Available at: https://youtu.be/X8dHbdhnGKY
www.youtube.com. (2018). Potentiometer Analog Input With Arduino in Tinkercad. [online] Available at: https://youtu.be/-EDYMQ9lczA
www.youtube.com. (2018). Blink an LED With Arduino in Tinkercad. [online] Available at: https://youtu.be/yyG0koj9nNY



Comments