Friday, January 16, 2015

Final Project - Megan and Becca

Our project is a light-up table that fits inside a game board box. The code consists of 23 RGB LEDs, which light up in a GRB sequence.We controlled the color like so: (G,R,B).  The operating LEDs snake around the board, building to the same color and then restart to change to a different color from the first LED. The color order goes red, green, blue, yellow, and white, then randomly begins to flash half the board in an unpredictable sequence, and then begins over with red.

CODE:


#include <Adafruit_NeoPixel.h>


#define PIN            7


#define NUMPIXELS      23


Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int delayval = 250;

void setup() {
  pixels.begin();
}

void loop() {
 
  for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(0,150,0));
    pixels.show();
    delay(delayval);
  }
    for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(150,0,0));
    pixels.show();
    delay(delayval);
  }
    for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(0,0,150));
    pixels.show();
    delay(delayval);
 
  }
    for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(150,150,0));
    pixels.show();
    delay(delayval);
  }
    for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(122,122,122));
    pixels.show();
    delay(delayval);
  }
    for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(0,150,0));
    pixels.show();
    delay(delayval);
  }
}


The pictures and video for this project were emailed to you, because we could not get them to upload onto the blog itself.

Monday, November 17, 2014

Programming for Unit 6 - Challenge 1 Rock Paper Scissors

int LED = 9;
int LED2 = 8;
int LED3 = 7;
int sensorValueR = 13;
int val1;                        // variable for reading the pin status
int buttonStateR;
int sensorValueP = 12;
int val2;                        // variable for reading the pin status
int buttonStateP;
int sensorValueS = 11;
int val3;                        // variable for reading the pin status
int buttonStateS;
int sensorValueS2 = 5;
int val4;                        // variable for reading the pin status
int buttonStateS2;
int sensorValueP2 = 4;
int val5;                        // variable for reading the pin status
int buttonStateP2;
int sensorValueR2 = 3;
int val6;                        // variable for reading the pin status
int buttonStateR2;

void setup()
{
  Serial.begin(9600);
  pinMode(3, INPUT);

  Serial.begin(9600);
  pinMode(4, INPUT);

  Serial.begin(9600);
  pinMode(5, INPUT);

  Serial.begin(9600);
  pinMode(11, INPUT);

  Serial.begin(9600);
  pinMode(12, INPUT);

  Serial.begin(9600);
  pinMode(13, INPUT);

  pinMode(LED, OUTPUT);

  pinMode(LED2, OUTPUT);

  pinMode(LED3, OUTPUT);

}
void loop()
{
  sensorValueR2 = digitalRead(3);
  Serial.println(sensorValueR2);
  delay(100);

  sensorValueP2 = digitalRead(4);
  Serial.println(sensorValueP2);
  delay(100);

  sensorValueS2 = digitalRead(5);
  Serial.println(sensorValueS2);
  delay(100);

  sensorValueS = digitalRead(11);
  Serial.println(sensorValueS);
  delay(100);

  sensorValueP = digitalRead(12);
  Serial.println(sensorValueP);
  delay(100);

  sensorValueR = digitalRead(13);
  Serial.println(sensorValueR);
  delay(100);

  if(sensorValueR2==HIGH && sensorValueS==HIGH)
  {
    Serial.println("first");
    pinMode (LED3, OUTPUT);
    digitalWrite (LED3, HIGH);
      Serial.println("Player Two Wins");
    delay (100);
    digitalWrite (LED3, LOW);
  }

  if(sensorValueR2==HIGH && sensorValueP==HIGH)
  {
    Serial.println("second");
    pinMode (LED, OUTPUT);
    digitalWrite (LED, HIGH);
    delay (100);
    digitalWrite (LED, LOW);
    if (val2 == LOW) {                // check if the button is pressed
      Serial.println("Player One Wins");
    }
  }    
  if(sensorValueR2==HIGH && sensorValueR==HIGH)
  {
    Serial.println("third");
    pinMode (LED2, OUTPUT);
    digitalWrite (LED2, HIGH);
    delay (100);
    digitalWrite (LED2, LOW);
    if (val1 == LOW) {                // check if the button is pressed
      Serial.println("TIE");
    }
  }
  if(sensorValueP2==HIGH && sensorValueS==HIGH)
  {
    Serial.println("fourth");
    pinMode (LED, OUTPUT);
    digitalWrite (LED, HIGH);
    delay (100);
    digitalWrite (LED, LOW);
    if (val3 == LOW) {                // check if the button is pressed
      Serial.println("Player One Wins");
    }
  }    
  if(sensorValueP2==HIGH && sensorValueP==HIGH)
  {
    Serial.println("fifth");
    pinMode (LED2, OUTPUT);
    digitalWrite (LED2, HIGH);
    delay (100);
    digitalWrite (LED2, LOW);
    if (val3 == LOW) {                // check if the button is pressed
      Serial.println("Tie");
    }
  }
  if(sensorValueP2==HIGH && sensorValueR==HIGH)
  {
    Serial.println("sixth");
    pinMode (LED3, OUTPUT);
    digitalWrite (LED3, HIGH);
    delay (100);
    digitalWrite (LED3, LOW);
    if (val1 == LOW) {                // check if the button is pressed
      Serial.println("Player One Wins");
    }
  }    
  if(sensorValueS2==HIGH && sensorValueS==HIGH)
  {
    Serial.println("seventh");
    pinMode (LED2, OUTPUT);
    digitalWrite (LED2, HIGH);
    delay (100);
    digitalWrite (LED2, LOW);
    if (val4 == LOW) {                // check if the button is pressed
      Serial.println("TIE");
    }
  }    
  if(sensorValueS2==HIGH && sensorValueP==HIGH)
  {
    Serial.println("eighth");
    pinMode (LED3, OUTPUT);
    digitalWrite (LED3, HIGH);
    delay (100);
    digitalWrite (LED3, LOW);
    if (val2 == LOW) {                // check if the button is pressed
      Serial.println("Player Two Wins");
    }
  }
  if(sensorValueS2==HIGH && sensorValueR==HIGH)
  {
    Serial.println("ninth");
    pinMode (LED, OUTPUT);
    digitalWrite (LED, HIGH);
    delay (100);
    digitalWrite (LED, LOW);

  }
}

Monday, September 29, 2014

Serial Communication

This is the programming that I used in order to write the Pythagorean theorem.

#include "math.h"               // include the Math Library

int a = 3;
int b = 4;
int h;

void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);           // set up Serial library at 9600 bps

  Serial.println("Lets calculate a hypoteneuse");

  Serial.print("a = ");
  Serial.println(a);

  Serial.print("b = ");
  Serial.println(b);
 
  h = sqrt( a*a + b*b );
 
  Serial.print("h = ");
  Serial.println(h);
}

void loop()              
{
}

Monday, September 22, 2014

Code for Blink Modification

Here is the code I used for the Blink Modification.

void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(100);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(100);    

Code for "There and Back Again: For Loop"

Here is the code that I used in the For Loop to make the LEDs light there and back again.


void loop()
{

  for (int led=13; led>=3; led--)
  {
    pinMode (led,OUTPUT);
    digitalWrite (led, HIGH);
    delay (100);
    digitalWrite (led, LOW);
   
  }
 
  for (int led=3; led<=13; led++)
  {
    pinMode (led, OUTPUT);
    digitalWrite (led, HIGH);
    delay (100);
    digitalWrite (led, LOW);
  }
 

Wednesday, September 10, 2014

Unit 3: Introduction to Arduino/Blink



My partner, Megan, and I started on the programming for our Arduino board early last week, and we started with learning how to hook up a resistor between 220 and 1000 ohms, three wires, and an LED into the breadboard in the format which would make the light turn on. We then learned how to make the light blink using the programming on our laptop,which figured out fairly quickly; the programming would name the LED according to whichever port on the Arduino the wire was docked, then turn it on and off with delays to say how long the light would be on or off. We also learned that there needed to be brackets before and after each function. Our next task after that was learning how to add another LED onto the breadboard (with accompanying resistor and wire) and make them blink with coordination so that one would always be on. This took a couple of days to figure out, because we would get close, but we wouldn't have it exact. Finally we realized that if the delay for the "off" is zero, the two lights will blink one after the other. Our third task, which we started yesterday, was to add at least three more LEDs and make them blink in a sequence, which just meant naming three more LEDs on the programming and adding their coordinating delay triggers. The lights on the breadboard go in order, by Green, Red, Green, Red, Green. Currently, Megan and I are working on making the lights blink so that the two reds blink at the same time, and the three greens blink together after that. So far we have the programming so that the similiar colored LEDs are on the same line, so they all follow he same command at the same time. I will post more information as we progress in the activities.

-Rebecca