• Facebook - White Circle
  • Instagram - White Circle
  • Twitter - White Circle

© 2019 by Mario the Maker Magician • 917.605.0662 • mariothemagician@gmail.com

Thank you for purchasing Mario's

Electronic Snake-in-a-Can Kit!

We are so happy to see that you're interested in taking things a step further!

First, download the Arduino software

Then, download this driver. (Use the image below as a guide.)

Finally, copy and paste this code into the Arduino program:

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

 

 

#include <Servo.h>

 

 

 

////MARIO THE MAKER MAGICIAN SNAKE IN A CAN CODE JAN. 2019

 

 

 

///THIS IS USED WITH TV REMOTE

 

 

 

/*

  AnalogReadSerial

   Reads an analog input on pin 0, prints the result to the serial monitor.

   Graphical representation is available using serial plotter (Tools > Serial Plotter menu)

   Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

 

   This example code is in the public domain.

 */

 

 

 Servo Snake;  // Add a second snake! Under Servo Snake; type Servo Snake2;

 

// the setup routine runs once when you press reset:

void setup() {

   // initialize serial communication at 9600 bits per second:

   Serial.begin(9600);

   

   Snake.attach(9); // THIS IS THE PIN THE SERVO IS CONNECTED TO

   

   //  FOR ADDING ANOTHER SNAKE under Snake.attach(9); put Snake2.attach(10); 2nd servo plugs to pin 10

 

   

   

   

}

 

// the loop routine runs over and over again forever:

void loop() {

  

   Snake.write(10); // CHANGE THE DEGREES FOR THE SERVO POSITION. HERE THE SERVO STARTS AT 10 Degrees

   

   delay(10); // WAIT a 10TH of a second

   

   // read the input on analog pin 0:

   int sensorValue = analogRead(A0); ///

   // print out the value you read:

   Serial.println(sensorValue);

   delay(1);        // delay in between reads for stability

   

   

   if (sensorValue < 500) { // IF THE SENSORVALUE IS LESS THAN 500 

     

     delay(100); // WAIT 100th of a second CHANGE THE WAIT PERIOD! delay(1000); means wait 1 second

     

     Snake.write(100); // MOVE SERVO TO 100 DEGREES

     

     delay(1000); //THEN WAIT 1 SECOND

     

     

     

   }

   

   else { // OR ELSE

     

      delay(10); //WAIT

     

      Snake.write(10); //GO BACK TO 10 DEGREES

   

  }

 

}

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////