Normally, when people talk about programming, people think it's very difficult, Arduino allows you to learn very fast, there are many levels of difficulty but the first steps with Arduino are easy.
Following algorithms we program in arduino, that is, you have to tell him step by step everything you want to do, it's like brushing your teeth, first you take the brush, then the paste, you brush, you rinse …
In arduino equal, you need information and we have to go in parts.
In void setup, all the components that we are going to use, LEDs, sensors, motors …
And in the void loop the sequence, repetition that you want to do with these components.
Example:
In this example we are going to use pin number 5 and declare it as output
void setup () {
pinMode (5, OUTPUT);
}
Next we write the loop, here we put what we want our pin 5 to do, which in this case is a buzzer.
void loop () {
tone (5,262,500); write to buzzer
delay (500);
tone (5,262,500); write to buzzer
delay (500);
tone (5,392,500); write to buzzer
delay (500);
On the official Arduino website you have many basic and simple examples to start the first steps. https://www.arduino.cc/
Examples: #include <Arduino.h>
#include <Wire.h>
#include <SoftwareSerial.h>
double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
void setup(){ pinMode(5,OUTPUT); }
void loop()
pinMode(5,HIGH);
tone(5,262,500); write to buzzer
delay(500);
tone(5,262,500); write to buzzer delay(500); tone(5,392,500); write to buzzer
delay(500);
tone(5,392,500); write to buzzer delay(500); tone(5,440,500); write to buzzer
delay(500);
tone(5,440,500); write to buzzer delay(500); tone(5,392,1000); write to buzzer
delay(1000);
tone(5,349,500); write to buzzer delay(500); tone(5,349,500); write to buzzer
delay(500);
tone(5,330,500); write to buzzer delay(500); tone(5,330,500); write to buzzer
delay(500);
tone(5,294,500); write to buzzer delay(500); tone(5,294,500); write to buzzer
delay(500);
tone(5,262,1000); write to buzzer delay(1000); tone(5,392,500); write to buzzer
delay(500);
tone(5,392,500); write to buzzer delay(500); tone(5,349,500); write to buzzer
delay(500);
tone(5,349,500); write to buzzer delay(500); tone(5,330,500); write to buzzer
delay(500);
tone(5,330,500); write to buzzer delay(500); tone(5,294,1000); write to buzzer
delay(1000);
tone(5,392,500); write to buzzer delay(500); tone(5,392,500); write to buzzer
delay(500);
tone(5,349,500); write to buzzer delay(500); tone(5,349,500); write to buzzer
delay(500);
tone(5,330,500); write to buzzer delay(500); tone(5,330,500); write to buzzer
delay(500);
tone(5,294,1000); write to buzzer delay(1000); tone(5,262,500); write to buzzer
delay(500);
tone(5,262,500); write to buzzer delay(500); tone(5,392,500); write to buzzer
delay(500);
tone(5,392,500); write to buzzer delay(500); tone(5,440,500); write to buzzer
delay(500);
tone(5,440,500); write to buzzer delay(500); tone(5,392,1000); write to buzzer
delay(1000);
tone(5,349,500); write to buzzer delay(500); tone(5,349,500); write to buzzer
delay(500);
tone(5,330,500); write to buzzer delay(500); tone(5,330,500); write to buzzer
delay(500);
tone(5,294,500); write to buzzer
delay(500);
tone(5,294,500); write to buzzer
delay(500);
tone(5,262,1000); write to buzzer
delay(1000);
_loop();
}
void _delay(float seconds){
long endTime = millis() + seconds * 1000;
while(millis() < endTime)_loop();
}
void _loop(){
}
If you do not have an Arduino and want to practice you can do it on this page. http://https://circuits.io/
You just have to register and start, it's very easy, you just have to choose your components and start programming.
Back http://wiki.textile-academy.org/fabricademy2017/students/anamaria.martinlopez/final_project