Algoritmos para Arduino
Algoritmos para Arduino
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
/* give it a name:
int led12 = 12;
int led11 = 11;
int led10 = 10;
int led9 = 9;
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
for (int i=9; i < 13; i++) {
pinMode(i, OUTPUT);
}
}
// the loop routine runs over and over again forever:
void loop() {
for(int i=9; i < 13; i++) {
digitalWrite(i, HIGH); // turn the LED on (HIGH is the voltage level)
delay(50);
// wait for a second
digitalWrite(i, LOW); // turn the LED off by making the voltage LOW
delay(50); // wait for a second
}
}
ejemplo 6 de arduino
int led = 9;
int brillo= 0;
int incremento = 5;
const int minimo=0;
const int maximo=255;
int tiempo=50;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
analogWrite(led,brillo);
brillo=brillo + incremento;
if (brillo == minimo || brillo == maximo) {
incremento = -incremento;
}
delay(50);
}
ejemplo numero 7
para medir el ponteciomentro
void setup() {
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead (A0);
Serial.println(sensorValue);
delay(100);
}
para entrar al monitor serial
control m o en herrramienta