Posts Tagged ‘ arduino ’

Serial conenction

Hooked up the arduino to the mac via USB and using Processing to show a visual reference to the connection which I’m manipulating via the potentiometer.

Servo and Tone

I think I’ve just made my own Theremin Machine. Or at least something to annoy the neighbors.

Stupid Pet trick

As part of every student in physical computing is to complete the stupid pet trick and mine is the “belly monitor”.

After some unusual ideas deliberated over in class, I’ve ended up with a belly monitor that monitors your eating limit. Since this varies from person to person, I’ve decided to proceed with a two inch velcro bench to attach the device.

I first thought of using a flex sensor and that didn’t work. The numbers the felx sensor was giving me is just too random for my taste and it kept falling off the female connector even when I taped it together. Soldering is not a good idea since it may melt the sensor.

I ended up using a large force sensor which I have duct taped to the velcro belt procured from Home Depot.


Now that the sensor thing has been sorted out I wanted a portable power source. I connected a 9V battery and that wasn’t giving me power or should I say consistent readings as compared to a USB connection


So I dropped that idea.


I went back to USB power and decided that a sound once you reached your limit would be funny. So I installed a tone beeper thingy or an audio transducer. This now tells you if the device is activated and will slowly increase in tone as you reach the upper limit.


I decided to use a smaller breadboard since I wanted it to be as small as possible. There’s still space for a battery connection but at the moment this is what I have.

Using the code below, it gave life to my stupid pet trick.

//belly monitor
//Melissa A. dela Merced

const int ledPin = 7;
const int redLED=8;
int analogValue=0;
int brightness = 0;
int flex = analogRead(A1);

void setup(){

int flex = analogRead(A1);


void loop(){
flex = analogRead(A1);
analogValue = analogRead(A1);
brightness = analogValue/2;

flex = map(flex,0, 200, 255, 0); //sensor
flex = min(flex,400);
flex = max(flex,0);

analogWrite (redLED,flex);
int frequency = map(flex, 0,255,100,1000);
tone (5, frequency,10);


Christmas lights

There’s satisfaction to be had in watching lights blink especially when those lights turn on by your command.


The code is relatively simple enough now that I’ve had the weekend to digest the meaning of all these pins and ports.

//double lights green light and red light
void setup(){
pinMode(3,INPUT); //SWITCH
void loop(){
// if (digitalRead(3) == true) {
// else {
digitalWrite(5, false);
digitalWrite(4, true);
delay (500);
// }

Using the same setup but different program and allowing the “if”s and “else” commands, this tells the chip to perfrom an action that will respond differently. In this case, when the switch is pressed the light will either be switched between red and green.

Feeling a little bold, I added more lights.

Trying something out

I wanted to get the switch to cascade the lights using the code below but it seemed that it wasn’t reacting to the switch and thus acting on switching the lights on it’s own. I’ll work on it some more.

//christmas lights
void setup(){
pinMode(9,INPUT); //SWITCH
// pinMode(8,OUTPUT);
void loop(){
if (digitalRead(9) == true && digitalRead(2) ==true){
digitalWrite (2, true);
digitalWrite (3, true);
digitalWrite (4, true);
digitalWrite (5, true);
digitalWrite (6, true);
digitalWrite (7, true);
// digitalWrite (8, true);
//  delay(1000);
//digitalWrite (8, false);
digitalWrite (7, false);
digitalWrite (6, false);
digitalWrite (5, false);
digitalWrite (4, false);
digitalWrite (3, false);
digitalWrite (2, false);

Blink that light

We don’t give it much thought when we turn on a light bulb. For us it’s just a flick of the switch and that’s it! So it shouldn’t be too much trouble. Or could it?

I picked up the ITP PCOMP kit at the NYU Computer Store for around $93 including taxes. Inside it’s a box of chips, LEDs, wires, boards, cables and so on to supposedly help me make magic.




First thing to setup is the breadboard (that white thing above) and the arduino board to the plastic mounting. You’ll need screws for the arduino but the breadboard has doublesided tape.


No switches or anything just power up the LED using the microcontroller via USB power. Even if the kit comes with a 9V adapter, I think it’s safer using USB. You can’t accidentally burn out the circuits as the computer will automatically turn off the port if it detects a short.


What’s wrong with this picture?

The board via the PWR lead as marked by the red wire and inserted a resistor and a green LED. Obviously this wouldn’t work since the breadboard isn’t powered and there’s no way that the digital lead is going to provide power to the board.


Let’s get some power.

The Arduino app is another matter entirely. Even though the user interface is similar to Processing, some of the syntax and commands are similar to a point.

I used the code in class and replaced the port numbers since I was using different ones than the ones in class. I learned the important part was to keep it simple and understand the logic of the board and it’s there!


The trick to making the LED blink is all in code using the “delay(x)” .


The switch was more challenging than the earlier two.


Now this needed a little more patience since I was adding another item which is the switch that needed a separate command for the microcontroller to command.

I ended up with this board.


And there you have it! A working switch. I’ll toy around with kit some more over the weekend but it’s great building something with your hands or in this case my hands and the computer.