Aula ARDUINO FOTOS + CÓDIGO
Autor: Moura Games | Publicado: 2011-09-22T17:09:00-07:00







Código 1 - SUPERMÁQUINA/*Super maquina 1
 * --------------
 *
 *
 * Basicamente uma extensão do Piscar um LED
 *
 * (cleft) 2005 K3, Malmo University
 * @author: David Cuartielles
 * @hardware: David Cuartielles, Aaron Hallborg
 */

int pin2 = 2;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int pin7 = 7;
int timer = 100;

void setup(){
  pinMode(pin2, OUTPUT);
  pinMode(pin3, OUTPUT);
  pinMode(pin4, OUTPUT);
  pinMode(pin5, OUTPUT);
  pinMode(pin6, OUTPUT);
  pinMode(pin7, OUTPUT);
}

void loop() {
   digitalWrite(pin2, HIGH);
   delay(timer);
   digitalWrite(pin2, LOW);
   delay(timer);

   digitalWrite(pin3, HIGH);
   delay(timer);
   digitalWrite(pin3, LOW);
   delay(timer);

   digitalWrite(pin4, HIGH);
   delay(timer);
   digitalWrite(pin4, LOW);
   delay(timer);

   digitalWrite(pin5, HIGH);
   delay(timer);
   digitalWrite(pin5, LOW);
   delay(timer);

   digitalWrite(pin6, HIGH);
   delay(timer);
   digitalWrite(pin6, LOW);
   delay(timer);

   digitalWrite(pin7, HIGH);
   delay(timer);
   digitalWrite(pin7, LOW);
   delay(timer);

   digitalWrite(pin6, HIGH);
   delay(timer);
   digitalWrite(pin6, LOW);
   delay(timer);

   digitalWrite(pin5, HIGH);
   delay(timer);
   digitalWrite(pin5, LOW);
   delay(timer);

   digitalWrite(pin4, HIGH);
   delay(timer);
   digitalWrite(pin4, LOW);
   delay(timer);

   digitalWrite(pin3, HIGH);
   delay(timer);
   digitalWrite(pin3, LOW);
   delay(timer);
}
Código 2/* Super Maquina 2
 * --------------
 *
 * Reduzindo a quantidade de código usando o for(;;)
 *
 * (cleft) 2005 K3, Malmo University
 * @author: David Cuartielles
 * @hardware: David Cuartielles, Aaron Hallborg
 */

int pinArray[] = {2, 3, 4, 5, 6, 7};
int count = 0;
int timer = 100;

void setup(){
  // fazendo todas as declarações de uma vez
  for (count=0;count&lt;6;count++) {
    pinMode(pinArray[count], OUTPUT);
  }
}

void loop() {
  for (count=0;count&lt;6;count++) {
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer);
  }
  for (count=5;count&gt;=0;count--) {
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer);
  }
}
Código 3/* Super Maquina 3
 * --------------
 *
 * Este exemplo é focado em fazer o efeito visual mais fluido
 *
 *
 * (cleft) 2005 K3, Malmo University
 * @author: David Cuartielles
 * @hardware: David Cuartielles, Aaron Hallborg
 */

int pinArray[] = {2, 3, 4, 5, 6, 7};
int count = 0;
int timer = 30;

void setup(){
  for (count=0;count&lt;6;count++) {
    pinMode(pinArray[count], OUTPUT);
  }
}

void loop() {
  for (count=0;count&lt;5;count++) {
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count + 1], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer*2);
  }
  for (count=5;count&gt;0;count--) {
   digitalWrite(pinArray[count], HIGH);
   delay(timer);
   digitalWrite(pinArray[count - 1], HIGH);
   delay(timer);
   digitalWrite(pinArray[count], LOW);
   delay(timer*2);&nbsp;



EXEMPLO 1


/*Programa desenvolvido por Gamesh_ http://brasilrobotics.blogspot.com/06/01/2011*/int ledPin1 =11;int ledPin2 =10;
void setup() {
pinMode(ledPin1, OUTPUT);pinMode(ledPin2, OUTPUT);}
void loop(){digitalWrite(ledPin1, HIGH);digitalWrite(ledPin2, LOW);delay(1000);
}&nbsp;&nbsp;&nbsp;EXEMPLO 2&nbsp;/*Programa desenvolvido por Gamesh_ http://brasilrobotics.blogspot.com/06/01/2011*/int ledPin1 =11;int ledPin2 =10;
&nbsp;void setup() {
&nbsp;pinMode(ledPin1, OUTPUT);pinMode(ledPin2, OUTPUT);}
&nbsp;void loop(){digitalWrite(ledPin1, LOW);digitalWrite(ledPin2, HIGH);delay(1000);
&nbsp;} &nbsp;&nbsp;EXEMPLO 3&nbsp; /*Programa desenvolvido por Gamesh_ http://brasilrobotics.blogspot.com/06/01/2011*/int ledPin1 =11;int ledPin2 =10;&nbsp;void setup() {
&nbsp;pinMode(ledPin1, OUTPUT);pinMode(ledPin2, OUTPUT);}&nbsp;&nbsp;void loop(){digitalWrite(ledPin1, HIGH);digitalWrite(ledPin2, LOW);delay(1000);
&nbsp;digitalWrite(ledPin1, LOW);digitalWrite(ledPin2, HIGH);delay(1000);
&nbsp;}



<embed src="https://www.youtube.com/get_player" type="application/x-shockwave-flash"
width="320" height="266" bgcolor="#FFFFFF"
flashvars="flvurl=https://redirector.googlevideo.com/videoplayback?requiressl%3Dyes%26id%3Db114075c04e6d4ef%26itag%3D5%26source%3Dblogger%26app%3Dblogger%26cmo%3Dsecure_transport%253Dyes%26cmo%3Dsensitive_content%253Dyes%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1495012237%26sparams%3Drequiressl,id,itag,source,ip,ipbits,expire%26signature%3D7D37C496C0FEC7608F1107AD9EE552DC53A03EB5.2B0C2ABC93E3F9E96638DADF5C95D640836FA6D4%26key%3Dck2&iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3Db114075c04e6d4ef%26offsetms%3D5000%26itag%3Dw160%26sigh%3DMPTzNKJ3gxz-PuoGlZLPbWIXzIc&autoplay=0&ps=blogger"
allowFullScreen="true" />