Commit 58d66ec7 authored by Rafael Peretti Pezzi's avatar Rafael Peretti Pezzi

Programa de teste do shield

parents
/*
Testa as funcionalidades do shield arduino basico do
Centro de Tecnologia Academica - IF/UFRGS
*/
// Leds nos pinos 9, 10, 11, 12 e 13
int leds[5] = {13,12,11,10,9};
int delay_t=50;
//Pino do botao
int pushButton = 2;
void setup() {
//Configura as portas como saida
for(int i=0;i<5;i++) { pinMode(leds[i], OUTPUT); }
// Configura o pino 2 do botao como entrada
pinMode(pushButton, INPUT);
// Liga o resistor pullup do pino 2
digitalWrite(pushButton, HIGH);
//Inicializa a comunicacao Serial
Serial.begin(9600);
}
void loop() {
if(digitalRead(2))
for(int i=0;i<5;i++) {
digitalWrite(leds[i], HIGH); // turn the LED on (HIGH is the voltage level)
delay(delay_t);
digitalWrite(leds[i], LOW); // turn the LED off by making the voltage LOW
}
else
for(int j=4;j>=0;j--) {
digitalWrite(leds[j], HIGH); // turn the LED on (HIGH is the voltage level)
delay(delay_t); // wait for a second
digitalWrite(leds[j], LOW); // turn the LED off by making the voltage LOW
}
//Carrega os valores das leituras do potenciometro e LDR
// nas portas analgicas
int sensorValue0 = analogRead(A0);
int sensorValue1 = analogRead(A1);
// Envia para a saida serial
Serial.println(" ");
Serial.print(sensorValue0);
Serial.print(" ");
Serial.println(sensorValue1);
// delay(100);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment