TICKLE ROBOT

FUNCIONAMIENTO
Al tocar el corazón del robot que está recubierto de aluminio, actúa como un sensor e inicia el funcionamiento del motor y se mueven las piernas y los brazos.

CÓDIGO
#include <SPI.h>
#include <SD.h>
#include <EducationShield.h>

//Necessary to include Servo.h when using Servo
#include <Servo.h>

//Necessary to include CapacitiveSensor.h when using capacitive sensor
#include <CapacitiveSensor.h>

//Declare the servo for controlling the string robot
Servo pull;

//Declare the capacitive sensor
CapacitiveSwitch sensor=CapacitiveSwitch(2,3);

void setup(){
  //initialize the capacitive sensor. Threshold is 400
  //See the example CapacitiveSwitchTest in the Help folder
  //to find the right thresshold
  sensor.config(2000);

  //initialize the servo motor
  pull.attach(9);
}
void loop(){
  if(sensor.getState()){
//If the capacitive sensor is touched, pull the strings
    pull.write(0);
  }else{
//Otherwise, loosen the strings
    pull.write(90);
  }
  delay(30);

}

VÍDEO DE FUNCIONAMIENTO

Comentarios

Entradas populares de este blog

MOTOR ARDUINO ACCIONADO CON SENSOR