Champaign-Urbana Community Fab Lab
Illinois Informatics and School of Information Sciences
Champaign-Urbana Community Fab Lab

Arduino Assignment

This week, we explored the program Arduino with resistors, an LED, breadboards, and Arduino Uno boards. In lab, we followed a straightforward step-by-step presentation in order to get the program and hardware to perform blinking. Then, we added aluminum foil to create a touch sensor and played around with resistance by manipulating the code.

For the device of my own, I wanted to create something for my dog to alert someone at home if he wants to come upstairs. At home, we gate off the upstairs in the daytime because there’s been few times that he’s run up with muddy feet. His bed is upstairs, so he is only allowed when he’s clean. My dog is really silent and often times he just waits there patiently.

Initially, I was expecting to use the joystick as the input, that if my dog were to bump his nose on it, a buzzer would sound. But when I got to lab, there weren’t any joysticks available. So I opted for a push button. At first, I set up all the hardware and software to perform a push button input for an LED output. Then I began to switch out and change the set up to accommodate for the buzzer. I took a look at two different working codes and began to intertwine them:

void setup() {

  // initialize the LED pin as an output:

  pinMode(ledPin, OUTPUT);

  // initialize the pushbutton pin as an input:

  pinMode(buttonPin, INPUT);

}

void loop() {

  // read the state of the pushbutton value:

  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:

  if (buttonState == HIGH) {

    // turn LED on:

    digitalWrite(ledPin, HIGH);

  } else {

    // turn LED off:

    digitalWrite(ledPin, LOW);

  }

}

int buzzer = 8 ;

void setup ()

{

  pinMode (buzzer, OUTPUT) ;

}

void loop ()

{

  unsigned char i, j ;

  while (1)

  {

    for (i = 0; i <80; i++) // When a frequency sound

    {

      digitalWrite (buzzer, HIGH) ; //send tone

      delay (1) ;

      digitalWrite (buzzer, LOW) ; //no tone

      delay (1) ;

    }

    for (i = 0; i <100; i++) 

    {

      digitalWrite (buzzer, HIGH) ;

      delay (2) ;

      digitalWrite (buzzer, LOW) ;

      delay (2) ;

    }

  }

}


I had to do a lot of testing of different codes and a lot of research online before I could get it to work. I watched a really helpful tutorial and had to do a few minor adjustments because the breadboard I was using was much smaller than in the tutorial. The buzzer was a lot quieter, but overall I’m satisfied with the process and the result.

Tags: , ,