ARDUINO π»
INPUT:
1a. Potentiometer analog input in tinkercad:
I then duplicate the code and changed HIGH to LOW:

After rearranging the wires, this is how it looks like (as shown below):
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 light on
digitalWrite(LED_BUILTIN, HIGH);
// pause the program for <sensorValve>
// milliiseconds
delay(sensorValue); // Wait for sensorValue millisecond(s)
// turn the LED light off
digitalWrite(LED_BUILTIN, LOW);
// pause the program for <sensorValve>
// milliiseconds
delay(sensorValue); // Wait for sensorValue millisecond(s)
}
Interface a LDR to maker UNO board and measure its
signal in serial monitor Arduino IDE:
1b. In this task, to interface a LDR to maker UNO board, LDR is used to replace the
Code:
// C++ code
//
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite(LED_BUILTIN, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}
The below video is the simulation of this task:
OUTPUT:
2a. After doing Input on tinkercad, I realise that it was really difficult to see the wires so now, I decided to use different colour wires as shown:
Create "brightness" to the variable:
Did the coding and this is what I got:
I realised that I did not change "i" to "brightness", thus, I changed it and did the simulation again:
Adding 2 more LED to the breadboard:
Code:
// C++ code
//
/*
Fade
*/
int brightness = 0;
int i = 0;
void setup()
{
pinMode(9, OUTPUT);
}
void loop()
{
for (brightness = 0; brightness <= 255; brightness += 5) {
analogWrite(9, brightness);
delay(30); // Wait for 30 millisecond(s)
}
for (brightness = 255; brightness <= 0; brightness += 5) {
analogWrite(9, brightness);
delay(30); // Wait for 30 millisecond(s)
}
}
2b. Interface the DC motor to maker UNO board and
program it to on and off using push button on the board
REFLECTION:
In this Arduino lesson,
it was my first time doing any form of coding and everything looked so foreign
to me in the beginning. The learning package in blackboard really helped me as
it has all the step by step ways to code. It not only showed me the coding, it
also gave me insides on what other Arduino boards are there (eg. speeduino,
Arduino UNO Rev3, and Maker UNO. Following the procedure/process given, the
class were to complete the challenges individually, the 4 tasks were:
1. Hello World!
2. Programmable button
3. Make some noise!
4. Servo Motor
This individual tasks are
important as it helps to build the basics in coding, it is also important as it
would help us with the competency test during practical. I used to think that
coding was very complicated and that there were many things to take not of. Now
I think that, after getting my basics of coding right, I am able to play around
with the codes and see what happens, it is actually quite fun and interesting!
So next I will try more features (different codes) and even challenge myself to
try combining blinking, sound, button, or servo together where all codes are
acting at the same time.
Comments
Post a Comment