Taller De Arduino
* Programar un cronometro que cuente hasta 2 minutos y luego encienda los motores para que el móvil dibuje un circulo:
#include <LiquidCrystal.h>int m,s;
int tiempo;
int mu, md, su, sd;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
pinMode(8,OUTPUT);
digitalWrite(8,LOW);
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("Cronometro:");
lcd.setCursor(10,1);
lcd.print("00:00");
}
void loop() {
tiempo= millis();
m= tiempo/60000;
mu= m%10;
md=(m-mu)/10;
s= (tiempo/1000)-(m*60);
su= s%10;
sd= (s-su)/10;
lcd.setCursor(8,1);
lcd.print(md);
lcd.print(mu);
lcd.print(":");
lcd.print(sd);
lcd.print(su);
if(lcd.print("02.00")){
circulo();
}
}
void circulo (){
}
*Programar un móvil que espere 20 segundos inmediatamente después avanze un metro, espere 10 segundos y después dibuje un cuadrado oun rombo.
Serial.begin (9600);
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(3, OUTPUT); //Salida motor 1 pinMode(5, OUTPUT); //Salida motor 1
pinMode(6, OUTPUT); // Salida motor 2
pinMode(9, OUTPUT); // Salida motor 2
pinMode(13, OUTPUT);
pinMode(12, INPUT);
digitalWrite(12,HIGH);
}void loop() {
if(digitalRead(12) == LOW) {
delay(20000);
adelante(1500,200);
delay(10000);
cuadrado();
rombo();
}
else {
}
}
void cuadrado ()
{ adelante(1000,128);
delay(100);
derecha(175 ,200);
delay(100);
adelante(1000,128);
delay(100);
derecha(175,200);
delay(100);
adelante(1000,128);
delay(100);
derecha(175,200); delay(100);
adelante(1000,128);
delay(100);
}
void rombo ()
{
giromenor(80,200);
delay(100);
adelante(1000,128);
delay(100);
derecha(265,700);
delay(100);...
Regístrate para leer el documento completo.