-
The Arduino code for "Bored No More"
08/20/2014 at 23:46 • 0 commentsThe Arduino code for "Bored No More"
#include <PWMServo.h>
#include <Wire.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_PWMServoDriver.h"
#include <Adafruit_NeoPixel.h>
//neopixels
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(120, PIN, NEO_GRB + NEO_KHZ800);
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// 513 stepper motor on pin 1
Adafruit_StepperMotor *myMotor = AFMS.getStepper(513, 1);
Adafruit_DCMotor *myMotorDCSpin = AFMS.getMotor(3);
Adafruit_DCMotor *myMotorDCCan = AFMS.getMotor(4);
const int buttonPin1 = 0; // the number of the red pushbutton pin
const int buttonPin2 = 1; // the number of the white pushbutton pin
const int buttonPin3 = 2; // the number of the blue pushbutton pin
const int buttonPin4 = 3; // the number of the green pushbutton pin
const int buttonPin5 = 4; // the number of the yellow pushbutton pin
const int ledPin1 = 5; // the number of the red LED pin
const int ledPin2 = 7; // the number of the white LED pin
const int ledPin3 = 8; // the number of the blue LED pin
const int ledPin4 = 11; // the number of the green LED pin
const int ledPin5 = 12; // the number of the yellow LED pin
int button1State = 0; // variable for reading the red pushbutton status
int button2State = 0; // variable for reading the white pushbutton status
int button3State = 0; // variable for reading the blue pushbutton status
int button4State = 0; // variable for reading the green pushbutton status
int button5State = 0; // variable for reading the yellow pushbutton status
PWMServo myservoDoor; // create servo object to control the door servo
PWMServo myservoArrow; // create servo object to control the arrow servo
int posArrow = 100; // variable to store the arrow servo position
void setup()
{
myservoArrow.attach(SERVO_PIN_A); // servo on pin 9 to the servo object
myservoDoor.attach(SERVO_PIN_B); // servo on pin 10 to the servo object
AFMS.begin(); // create with the default frequency 1.6KHz
myMotor->setSpeed(5); // 5 rpm
strip.begin(); // start
strip.show(); // Initialize all pixels to 'off'
for(uint16_t i=0; i<95; i++)
{
strip.setPixelColor(i, 204, 0, 102);
strip.show();
delay(15);
}
// initialize the LED pin as an output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
pinMode(ledPin4, OUTPUT);
pinMode(ledPin5, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
// turns on LEDs in all the buttons
digitalWrite(ledPin1, HIGH);
digitalWrite(ledPin2, HIGH);
digitalWrite(ledPin3, HIGH);
digitalWrite(ledPin4, HIGH);
digitalWrite(ledPin5, HIGH);
myMotorDCSpin->setSpeed(150);
myMotorDCSpin->run(FORWARD);
myMotorDCSpin->run(RELEASE);
myMotorDCCan->setSpeed(150);
myMotorDCCan->run(FORWARD);
myMotorDCCan->run(RELEASE);
}
void loop()
{
sweep(); // sweep arrow
}
void sweep() // sweep arrow
{ // and check for button press
for(posArrow = 0; posArrow < 100; posArrow += 1) // goes from 0 to 180 degrees
{
Button1();
Button2();
Button3();
Button4();
Button5();
myservoArrow.write(posArrow); // tell servo to go to'posArrow'
delay(15); // servo to reach the position
}
for(posArrow = 100; posArrow>=1; posArrow -= 1) // goes from 180 to 0 degrees
{
Button1();
Button2();
Button3();
Button4();
Button5();
myservoArrow.write(posArrow); // tell servo to go to'posArrow'
delay(15); // servo to reach the position
}
}
void Button1()
{
button1State = digitalRead(buttonPin1); // read the state of buttons
if (button1State == HIGH) // check if button is pressed
{
myservoDoor.write(3); // close door
//turn off neopixels for Problem
strip.setPixelColor(96, 0, 0, 0);
strip.setPixelColor(97, 0, 0, 0);
strip.setPixelColor(98, 0, 0, 0);
strip.setPixelColor(99, 0, 0, 0);
//turn off neopixels for Hypothesis
strip.setPixelColor(100, 0, 0, 0);
strip.setPixelColor(101, 0, 0, 0);
strip.setPixelColor(102, 0, 0, 0);
strip.setPixelColor(103, 0, 0, 0);
strip.show(); // send signal to neopixels
}
else
{
myservoDoor.write(91); // open door
//turn on RED neopixels for Problem
strip.setPixelColor(96, 255, 0, 0);
strip.setPixelColor(97, 255, 0, 0);
strip.setPixelColor(98, 255, 0, 0);
strip.setPixelColor(99, 255, 0, 0);
//turn on RED neopixels for Hypothesis
strip.setPixelColor(100, 255, 0, 0);
strip.setPixelColor(101, 255, 0, 0);
strip.setPixelColor(102, 255, 0, 0);;
strip.setPixelColor(103, 255, 0, 0);
strip.show(); // send signal to neopixels
myMotor->step(86, FORWARD, SINGLE); // spins the wheel 86 steps
myMotor->release(); // releases the stepper motor
delay(5000); // wait
myservoDoor.write(3); // close door
}
}
void Button2()
{
button2State = digitalRead(buttonPin2); // read the state of buttons
if (button2State == HIGH) // check if button is pressed
{
//turn off neopixels for Research
strip.setPixelColor(116, 0, 0, 0);
strip.setPixelColor(117, 0, 0, 0);
strip.setPixelColor(118, 0, 0, 0);
strip.setPixelColor(119, 0, 0, 0);
strip.show(); // send signal to neopixels
}
else
{
//turn on WHITE neopixels for Research
strip.setPixelColor(116, 255, 229, 204);
strip.setPixelColor(117, 255, 229, 204);
strip.setPixelColor(118, 255, 229, 204);
strip.setPixelColor(119, 255, 229, 204);
strip.show(); // send signal to neopixels
myMotor->step(86, FORWARD, SINGLE); // spins the wheel 86 steps
myMotor->release(); // releases the stepper motor
delay(5000); // wait
}
}
void Button3()
{
button3State = digitalRead(buttonPin3); // read the state of buttons
if (button3State == HIGH) // check if button is pressed
{
//turn off neopixels for Build
strip.setPixelColor(112, 0, 0, 0);
strip.setPixelColor(113, 0, 0, 0);
strip.setPixelColor(114, 0, 0, 0);
strip.setPixelColor(115, 0, 0, 0);
strip.show(); // send signal to neopixels
}
else
{
//turn on BLUE neopixels for Build
strip.setPixelColor(112, 0, 0, 255);
strip.setPixelColor(113, 0, 0, 255);
strip.setPixelColor(114, 0, 0, 255);
strip.setPixelColor(115, 0, 0, 255);
strip.show(); // send signal to neopixels
myMotor->step(86, FORWARD, SINGLE); // spins the wheel 86 steps
myMotor->release(); // releases the stepper motor
myMotorDCSpin->run(FORWARD);
myMotorDCSpin->setSpeed(150);
delay(2000);
myMotorDCSpin->run(RELEASE);
delay(5000); // wait
}
}
void Button4()
{
button4State = digitalRead(buttonPin4); // read the state of buttons
if (button4State == HIGH) // check if button is pressed
{
//turn off neopixels for Results
strip.setPixelColor(108, 0, 0, 0);
strip.setPixelColor(109, 0, 0, 0);
strip.setPixelColor(110, 0, 0, 0);
strip.setPixelColor(111, 0, 0, 0);
strip.show(); // send signal to neopixels
}
else
{
//turn on GREEN neopixels for Results
strip.setPixelColor(108, 0, 255, 0);
strip.setPixelColor(109, 0, 255, 0);
strip.setPixelColor(110, 0, 255, 0);
strip.setPixelColor(111, 0, 255, 0);
strip.show(); // send signal to neopixels
myMotor->step(86, FORWARD, SINGLE); // spins the wheel 86 steps
myMotor->release(); // releases the stepper motor
delay(5000); // wait
}
}void Button5()
{
button5State = digitalRead(buttonPin5); // read the state of buttons
if (button5State == HIGH) // check if button is pressed
{
//turn off neopixels for Conclusion
strip.setPixelColor(104, 0, 0, 0);
strip.setPixelColor(105, 0, 0, 0);
strip.setPixelColor(106, 0, 0, 0);
strip.setPixelColor(107, 0, 0, 0);
strip.show(); // send signal to neopixels
}
else
{
//turn on Yellow neopixels for Conclusion
strip.setPixelColor(104, 255, 255, 0);
strip.setPixelColor(105, 255, 255, 0);
strip.setPixelColor(106, 255, 255, 0);
strip.setPixelColor(107, 255, 255, 0);
strip.show(); // send signal to neopixels
myMotor->step(86, FORWARD, SINGLE); // spins the wheel 86 steps
myMotor->release(); // releases the stepper motor
myMotorDCCan->run(BACKWARD);
myMotorDCCan->setSpeed(180);
delay(500);
myMotorDCCan->run(RELEASE);
myMotorDCCan->setSpeed(50);
delay(3000);
myMotorDCCan->run(RELEASE);
}
} -
Next Time I Will Take More Pictures During Build
08/14/2014 at 15:42 • 0 commentsYou live you learn. I promise myself I will take more pictures during my next build. Taking some components apart to get good photos today. When I should of taken them while I was building (would of been so much easier). Lesson learned there is never to much documentation. What other leseons have other makers learned the hard way? Please let me know!
-
Hopes and Dreams
08/13/2014 at 13:09 • 0 commentsHopes and dreams of things I would like to add but do not have the budget to do at this time.
- Led bar graphs (Led's change and move in respect to science project data)
- Requires additional LED strips
- Moving dial displays (Servo powered and move in respect to science project data)
- Requires multi channel servo controller
- More doors (Flip up, barn door style, and sliding doors powered by servos)
- Requires multi channel servo controller
- Sound effects (to go along with activated movement)
- Requires MP3 shield, speakers, and amplifier
- Recorded messages (explain data being displayed by activated feature)
- Requires MP3 shield, speakers, and amplifier
- More buttons, switches, and knobs
- Use to activate features and because they add interactivity
- Led bar graphs (Led's change and move in respect to science project data)
-
The Plan
08/12/2014 at 22:45 • 0 commentsTo show what is possible with a interactive Science Fair board. By using cheap components, a little arts and crafts, and the power of imagination Science Fairs can be interesting to all students and parents. This might inspire the future generation to become engineers.
-
Maker Faire Detroit 2014
08/12/2014 at 15:02 • 0 commentsJust returned from a successful showing at Maker Faire Detroit. Thanks to everyone who stopped by and saw my project. Proud recipiant of a "Maker of Merit" blue ribbon. I am excited by the interest and feedback I received. I will be adding more images and instructions to this project shortly. Please stay tuned.