Monday, February 18, 2013

Random Arduino Fun

Here's what I came up with putzing with different code projects. As you hold the button down, the light will flicker and pulse, but when it's not pressed, you have manual control turning it up or down. Here's the code:


int ledPin = 6;

int buttonPin = 3;

int buttonPressed = 0;

int bright = 0;

int dir = 1;

int potPin = A0;

int newValue = 0;

int potValue = 0;

void setup(){
  Serial.begin (9600);

  pinMode (ledPin, OUTPUT);

  pinMode (buttonPin, INPUT);

  pinMode (potPin, INPUT);

  digitalWrite (buttonPin, HIGH);
}

void loop (){

  buttonPressed = digitalRead (buttonPin);

    Serial.println (buttonPressed);
 
    bright = bright + dir;
    delay (100);
 
     potValue = analogRead(potPin);

  newValue = map(potValue, 0, 1023, 0, 200);

//Serial.print (potValue);

Serial.println (newValue);
 
    if (buttonPressed == 0){
      digitalWrite(ledPin, HIGH);
  dir += -1;
    }
 
    else{
      analogWrite (ledPin, newValue);
      bright = newValue;
    }

  analogWrite(ledPin, bright);

  if (bright >= 255){
    bright = 0;
  }
}

Wednesday, February 13, 2013

By The Press of a Button


By now, you've no doubt been blown away. When not pressing the button, the red light shines. When you do press the button, the blue light pulses. Here's the code:


Sunday, February 10, 2013

Three Lights

Check these lights out! Blink, blink, blink, BLINK! Here's the code:

Wednesday, February 6, 2013

Basic Code



Oh man, check this out! It prints stuff, it loops, and it milks a meme from 2007! Cooooooooool!!!

Sunday, February 3, 2013

Project #1

I made this. It was fun. It dims. The video's audio is general jackass-ery. No apologies.