|
always under construction A tentative course planstep 1 - Install partyYou need either 1) get an Arduino or 2) use online simulated Arduino. I prefer 1) becase I find it better but 2) is also ok 1) install Arduino SW on your PC Find version to your operating system 2) See hw.html I prefer TinkerCad step 2 - My first programJust read and follow instructions in arduino_comic.pdf The goal to make the LED on pin 13 to blink step 3 - Serial communicationYou can communicate with your Arduino on a text channel (serial) by the USB cable. Please note that you need to set communication speed before using the serial communication: Setting Serial speed in your arduino program Serial.begin(9600); // ~ 900 characters pr second ... Serial.begin(115200); // ~ 1000 characters pr second You can open a serial terminal in the PC Arduino SW. You must set the same speed as in the program. I will suggest Serial.begin(115200);
// The setup function is called once in the beginning
void setup() {
Serial.begin(115200); // open the serial port at 115200 bps:
}
int helTal=0; //
// loop is called againg and again - therefore name loop
// we print 0,1,2,3,4.... with half second delay between every print
void loop() {
Serial.println(helTal); // println add a newline in the end (indicated by ln in name)
helTal = helTal + 1; // or short helTal++;
delay(500); // wait 500 milliseconds (1/2 second)
}
The exercise 3 - make a for loop inside the loop function and print the first 20 elements of 3,6,13 table. step 4 - LoopsSee movie about loops in step 3 and make a program that print first 25 Fibonacci numbers. See https://en.wikipedia.org/wiki/Fibonacci_sequence If you want line shift use println instead of print An example
void setup()
{
Serial.begin(115200);
}
void loop()
{
for (int counter=0; counter < 10; counter++)
{
println(2*counter);
}
delay(1000);
}
//output
0
2
4
6
8
10
12
14
16
18
step 5 - LoopsUse the blink program to make a program morse SOS on the LED (https://en.wikipedia.org/wiki/SOS)
Timing is critical. If we set duration of a dot to 1 then
step 6 - Digital inputJust see this video and do a copycat Jens |