arduino

Programming the camera

Because of my previous difficult experience with raspberry pi's and their camera module, I chose to go with the arduino. I had already spent a semester learning how to program with the Arduino Uno, and felt like building a camera with the knowledge that I had gained on it, would make this project a lot easier. It turned out the project didn't start off nearly as seamlessly as I expected it to. After hours of struggling, asking for help from classmates and professors, I was finally able to get the arduino camera working.

I purchased the data logging shield as directed to by an online source on building the camera, because they also suggested purchasing a WifiSD card so that the photos could be transferred online. I accidentally got the wifiSD shipped to my home in Maryland, so I wasn't able to use that part of the camera.

Below is a video of me putting the camera together, followed by photos I took with the camera:

assembling the camera via photos:

photos taken by the arduino:

The quality wasn't great and it took a really long time to save the photos onto the memory card. But, I figured the photo manipulations I'd do would cover up the poor quality. And, with me trying to make this camera closer to the film camera experience than to the digital camera experience (without being a film camera), the wait could be made into an illusion of photo processing.

A few people questioned why I was using an Arduino to build a camera, as opposed to a raspberry pi (which apparently would've been much easier). At the time, I wasn't fully aware of the difference in operation between the Arduino and Raspberry Pi, and had thought that I could only program a Raspberry Pi on a Windows or Linux system (which I found discouraging because it would be an extra hurdle since I only had a Mac - but, I later found that I just needed an external monitor and not one of those systems).

After the half week with the Arduino, and having invested money into the pieces, I very hesitantly decided to take the common advice and pursue the project with a Raspberry Pi.

Trying out my RGB LED with a Ribbon Sensor

I wanted to learn how to control my RGB LED with a soft-ribbon sensor. After following a few schematics on Google, getting help from a fellow student and finding a good code online, I was able to produce my first ribbon-sensor controlled RGB LED. I look forward to experimenting with the code more and understanding it better, so that I can get more creative with my LED. I would like to be able to control the LED with my piezo's and make it sound interactive, next.

I then tried again with two LED's.


 

The code was found here, on the arduino forum:

int potpin = 2;              // Switch connected to digital pin 2

int rpin = 9;
int gpin = 10;
int bpin = 11;
float h;
int h_int;
int r=0, g=0, b=0;

int val=0;

void h2rgb(float h, int &R, int &G, int &B);

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


void loop()                     // run over and over again
{
 val=analogRead(potpin);    // Read the pin and display the value
 //Serial.println(val);
 h = ((float)val)/1024;
 h_int = (int) 360*h;
 h2rgb(h,r,g,b);
 Serial.print("Potentiometer value: ");
 Serial.print(val);
 Serial.print(" = Hue of ");
 Serial.print(h_int);
 Serial.print("degrees. In RGB this is: ");
 Serial.print(r);
 Serial.print(" ");
 Serial.print(g);
 Serial.print(" ");
 Serial.println(b);

 analogWrite(rpin, r);
 analogWrite(gpin, g);
 analogWrite(bpin, b);
}

void h2rgb(float H, int& R, int& G, int& B) {

 int var_i;
 float S=1, V=1, var_1, var_2, var_3, var_h, var_r, var_g, var_b;

 if ( S == 0 )                       //HSV values = 0 ÷ 1
 {
   R = V * 255;
   G = V * 255;
   B = V * 255;
 }
 else
 {
   var_h = H * 6;
   if ( var_h == 6 ) var_h = 0;      //H must be < 1
   var_i = int( var_h ) ;            //Or ... var_i = floor( var_h )
   var_1 = V * ( 1 - S );
   var_2 = V * ( 1 - S * ( var_h - var_i ) );
   var_3 = V * ( 1 - S * ( 1 - ( var_h - var_i ) ) );

   if      ( var_i == 0 ) { 
     var_r = V     ; 
     var_g = var_3 ; 
     var_b = var_1 ;
   }
   else if ( var_i == 1 ) { 
     var_r = var_2 ; 
     var_g = V     ; 
     var_b = var_1 ;
   }
   else if ( var_i == 2 ) { 
     var_r = var_1 ; 
     var_g = V     ; 
     var_b = var_3 ;
   }
   else if ( var_i == 3 ) { 
     var_r = var_1 ; 
     var_g = var_2 ; 
     var_b = V     ;
   }
   else if ( var_i == 4 ) { 
     var_r = var_3 ; 
     var_g = var_1 ; 
     var_b = V     ;
   }
   else                   { 
     var_r = V     ; 
     var_g = var_1 ; 
     var_b = var_2 ;
   }

   R = (1-var_r) * 255;                  //RGB results = 0 ÷ 255
   G = (1-var_g) * 255;
   B = (1-var_b) * 255;
 }
}

Lighting the board with one LED and a switch

Learning how to light the switch, initially, felt very intimidating. I kept putting it off because I was scared of how challenging it might be to try to figure it out on my own. But, it became incredibly less intimidating as I followed the videos made by Jeff Feddersen and Tom Igoe, the website resources listed on our syllabus, and using the arduino guide book that came in my starter kit.

I started off trying to power the board with a 9V and a regulator. But, the regulator that came in my kit wasn't labeled "7805" as we were instructed to use, and the light wouldn't turn on. When I removed the battery and used the arduino, usb, and my computer, the light then started to begin to work.

I then downloaded the arduino program and was able to make the light blink at my programmed pace, which was exciting.