If you're seeing this message, it means we're having trouble loading external resources on our website.

Se você está atrás de um filtro da Web, certifique-se que os domínios *.kastatic.org e *.kasandbox.org estão desbloqueados.

Conteúdo principal

Programando a Aranha

Ensinando a Aranha a dançar

Agora é hora de ensinar a Aranha a dançar
1. Vá para: http://arduino.cc/en/main/software e baixe o software Arduino no sistema operacional do seu computador.
2. Inicie o Arduino e vá até Arquivo/Novo
Novo menu do Arduino
3. Vá em ferramentas e selecione Arduino Nano w / ATmega328
Próxima imagem Arduino
4.Conecte o cabo mini USB ao seu computador e o Arduino no seu robô Aranha.
Próxima imagem Arduino
5. Selecione a seguinte porta serial
Próxima imagem Arduino
6. Copie o código de dança mostrado a seguir (selecione-o e use ctrl c em um pc ou o comando c em um mac)
// Código de DANCE CODE para a aranha por Karl Wendt 1/15/13  
// Defina o pino de saída  
int Red_Eye_Left= 12; // LED connectado ao pino 12  
int Red_Eye_Right= 4; // LED connectado ao pino 4  
int Green_Eye_Left= 8; // LED connectado ao pino 8  
int Green_Eye_Right= 3; // LED connectado ao pino 3  
int Blue_Eye_Left= 7; // LED connectado ao pino 7  
int Blue_Eye_Right= 2; // LED connectado ao pino 2  
int Left_Reverse = 6; // Controle 1 do motor direito conectado ao pino 6  
int Left_Forward = 9; // Controle 2 do motor direito conectado ao pino 9  
int Right_Forward = 10; // Controle 1 do motor esquerdo conectado ao pino 10  
int Right_Reverse = 11; // Controle 2 do motor esquerdo conectado ao pino 11 
// Define o modo do pino (saída ou entrada)  
void setup() {
pinMode(Red_Eye_Left, OUTPUT); //sets the digital pin as output  
    pinMode(Red_Eye_Right, OUTPUT); //sets the digital pin as output  
    pinMode(Green_Eye_Left, OUTPUT); //sets the digital pin as output  
    pinMode(Green_Eye_Right, OUTPUT); //sets the digital pin as output  
    pinMode(Blue_Eye_Left, OUTPUT); //sets the digital pin as output  
    pinMode(Blue_Eye_Right, OUTPUT); //sets the digital pin as output  
    pinMode(Left_Forward, OUTPUT); // sets L1 the digital pin as output  
    pinMode(Left_Reverse, OUTPUT); // sets L2 the digital pin as output  
    pinMode(Right_Forward, OUTPUT); // sets L3 the digital pin as output  
    pinMode(Right_Reverse, OUTPUT); // sets L4 the digital pin as output  
}  
// Create your code loop  
void loop() {  
    digitalWrite(Red_Eye_Left, HIGH); //turns on left eye red LED  
    digitalWrite(Red_Eye_Right, HIGH); //turns on right eye red LED  
    delay(500); //run for half a second  
    digitalWrite(Red_Eye_Left, LOW); //turns off left eye red LED  
    digitalWrite(Red_Eye_Right, LOW); //turns off right eye red LED  
    digitalWrite(Green_Eye_Left, HIGH); //turns on left eye green LED  
    delay(500); //run for half a second  
    digitalWrite(Green_Eye_Left, LOW); //turns off left eye green LED  
    digitalWrite(Blue_Eye_Left, HIGH); //turns on left eye blue LED  
    delay(500); //run for half a second  
    digitalWrite(Blue_Eye_Left, LOW); //turns on left eye blue LED  
    delay(500); //run for half a second  
    digitalWrite(Green_Eye_Right, HIGH); //turns on right eye green LED  
    delay(500); //run for half a second  
    digitalWrite(Green_Eye_Right, LOW); //turns off right eye green LED  
    digitalWrite(Blue_Eye_Right, HIGH); //turns on right eye blue LED  
    delay(500); //run for half a second  
    digitalWrite(Blue_Eye_Right, LOW); //turns off right eye blue LED  
    delay(500); //run for half a second  
    //Make new colors by combining LED lights  
    digitalWrite(Blue_Eye_Left, HIGH); //turns on left eye blue LED  
    digitalWrite(Blue_Eye_Right, HIGH); //turns on right eye blue LED  
    digitalWrite(Red_Eye_Left, HIGH); //turns on left eye red LED  
    digitalWrite(Red_Eye_Right, HIGH); //turns on right eye red LED  
    delay(1000); //run for a quarter second  
    digitalWrite(Blue_Eye_Left, LOW); //turns on left eye blue LED  
    digitalWrite(Blue_Eye_Right, LOW); //turns on right eye blue LED  
    digitalWrite(Green_Eye_Left, HIGH); //turns on left eye green LED  
    digitalWrite(Green_Eye_Right, HIGH); //turns on right eye green LED  
    digitalWrite(Red_Eye_Left, HIGH); //turns on left eye red LED  
    digitalWrite(Red_Eye_Right, LOW); //turns on right eye red LED  
    delay(1000); //run for a quarter second  
    //Turn on the motors and make Spider move  
    analogWrite(Left_Reverse, 90); //run left motor backwards at PWM speed 90  
    delay(500); //run for half a second  
    analogWrite(Left_Reverse, 0); //stop left motor  
    delay(200); //run for 2 seconds  
    analogWrite(Right_Reverse, 90); //run right motor backwards at PWM speed 90  
    delay(500); //run for half a second  
    analogWrite(Right_Reverse, 0); //stop right motor  
    analogWrite(Left_Forward, 90); //run left motor forward at PWM speed 90  
    delay(500); //wait for half a second  
    analogWrite(Left_Forward, 0); //stop left motor  
    analogWrite(Right_Forward, 90); //run right motor forward at PWM speed 90  
    delay(500); //run for half a second  
    analogWrite(Right_Forward, 0); //stop right motor  
    analogWrite(Left_Reverse, 90); //run left motor backwards at PWM speed 90  
    delay(500); //run for half a second  
    analogWrite(Left_Reverse, 0); //stop left motor  
    delay(200); //run for 2 seconds  
    analogWrite(Right_Reverse, 90); //run right motor backwards at PWM speed 90  
    delay(500); //run for half a second  
    analogWrite(Right_Reverse, 0); //stop right motor  
    analogWrite(Left_Forward, 90); //run left motor forward at PWM speed 90  
    delay(500); //wait for half a second  
    analogWrite(Left_Forward, 0); //stop left motor  
    analogWrite(Right_Forward, 90); //run right motor forward at PWM speed 90  
    delay(500); //run for half a second  
    analogWrite(Right_Forward, 0); //stop right motor  
}
7. Cole o código no arquivo novo do Arduino que você acabou de criar (coloque o cursor sobre seu esboço do Arduino e pressione ctrl v ou comando v)
8. Clique na seta horizontal para carregar o código no seu robô Aranha
Próxima imagem Arduino
9. Desconecte o cabo USB
10. Ligue sua Aranha e veja-a dançar!
11. Se sua aranha não estiver se movendo rápido o suficiente, pode ser necessário aumentar a velocidade do motor.
AVISO: Certifique-se de que seu Robô Aranha está sobre uma piso liso e plano (NÃO EM CIMA DE UMA MESA), ele NÂO está ainda programado para evitar as orlas da mesa e irá cair, e pode quebrar.

Quer participar da conversa?

Nenhuma postagem por enquanto.
Você entende inglês? Clique aqui para ver mais debates na versão em inglês do site da Khan Academy.