Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Getting output into Mathematica? on: July 21, 2013, 11:50:57 pm
I've checked out the following link and had little success with this so far. I want to see the output of an arduino function in mathematica. How exactly do I do that? I believe I have the Serial IO downloaded and installed in the correct place.

Here is what I've followed thus far. I'm stuck trying to get my value "F" out of the Arduino.
http://playground.arduino.cc/Interfacing/Mathematica

Thanks.

ETA: It says "access to 'COM5' denied" That's the com port I've got the Arduino hooked up to and I have the ARduino IDE closed.
2  Community / Exhibition / Gallery / 2x2x2 LED Cube on: May 22, 2013, 03:27:08 pm
Here is a cube that I made with the help of my Students. I have included the code since I couldn't find anything simple enough for me to use on the internet.

http://www.youtube.com/watch?v=7atiYegk3a0&feature=youtu.be
Code:
/*Code provided by Brian W. Cordes 2013*/

int ledpins[] = {3,5,6,9};
int groundpins[] = {12,13};
void setup ()
{
  for(int i = 0; i < 4; i++)
  {       
      pinMode(ledpins[i],OUTPUT);
  }                         
  for (int i= 0; i<2; i++)
  {pinMode(groundpins[i],OUTPUT);}

}

void loop()
{
 twist();
 drop();
 diagonal();
}

void twist()
{
  int delaytime=100;
   digitalWrite(groundpins[0], HIGH);
    delay(100);   
  digitalWrite(ledpins[0], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[1], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[2], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[3], HIGH);
  delay(delaytime);
 
   digitalWrite(ledpins[0], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[1], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[2], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[3], LOW); 
 delay(delaytime);
 digitalWrite(groundpins[0], LOW);
 
 
 
 
 digitalWrite(groundpins[1], HIGH);
    delay(100);   
  digitalWrite(ledpins[1], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[2], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[3], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[0], HIGH);
  delay(delaytime);
 
   digitalWrite(ledpins[1], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[2], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[3], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[0], LOW); 
  delay(delaytime);
  digitalWrite(groundpins[1], LOW);
 
 
  digitalWrite(groundpins[0], HIGH);
    delay(100);   
  digitalWrite(ledpins[2], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[3], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[0], HIGH);
  delay(delaytime);               
  digitalWrite(ledpins[1], HIGH);
  delay(delaytime);
 
  digitalWrite(ledpins[2], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[3], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[0], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[1], LOW); 
  delay(delaytime);
  digitalWrite(groundpins[0], LOW);
 
  digitalWrite(groundpins[1], HIGH);
    delay(100);   
  digitalWrite(ledpins[3], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[0], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[1], HIGH); 
  delay(delaytime);               
  digitalWrite(ledpins[2], HIGH);
  delay(delaytime);
 
  digitalWrite(ledpins[3], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[0], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[1], LOW); 
  delay(delaytime);               
  digitalWrite(ledpins[2], LOW); 
  delay(delaytime);
  digitalWrite(groundpins[1], LOW);
}

void drop()
{
  int dtime = 75;
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[0], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1],HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[0], LOW);
 
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[1], LOW);
 
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[2], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[2], LOW);
 
   digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[3], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[3], LOW);
 
 
  //second time down
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[0], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1],HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[0], LOW);
 
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[1], LOW);
 
  digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[2], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[2], LOW);
 
   digitalWrite(groundpins[0], HIGH);
  digitalWrite(ledpins[3], HIGH);
  delay(dtime);
  digitalWrite(groundpins[0], LOW);
  digitalWrite(groundpins[1], HIGH);
  delay(dtime);
  digitalWrite(groundpins[1], LOW);
  digitalWrite(ledpins[3], LOW);
 
 
}
 
void diagonal()
{
 int dtime= 100;
 //bottom pin 0 on
 digitalWrite(groundpins[1], HIGH);
 digitalWrite(ledpins[0], HIGH);
 delay(dtime);
 //bottom pin 0 off
 digitalWrite(groundpins[1], LOW);
 digitalWrite(ledpins[0], LOW);
 delay(dtime);
 //top pin 1 on
 digitalWrite(groundpins[0], HIGH);
 digitalWrite(ledpins[1], HIGH);
 delay(dtime);
 //top pin 1 off
 digitalWrite(groundpins[0], LOW);
 digitalWrite(ledpins[1], LOW);
 //bottom pin 2 on
 digitalWrite(groundpins[1], HIGH);
 digitalWrite(ledpins[2], HIGH);
 delay(dtime);
 //bottom pin 2 off
 digitalWrite(groundpins[1], LOW);
 digitalWrite(ledpins[2], LOW);
  //top pin 3 on
 digitalWrite(groundpins[0], HIGH);
 digitalWrite(ledpins[3], HIGH);
 delay(dtime);
 //top pin 3 off
 digitalWrite(groundpins[0], LOW);
 digitalWrite(ledpins[3], LOW);
 
 
 
 
 
 //top pin 0 on
 digitalWrite(groundpins[0], HIGH);
 digitalWrite(ledpins[0], HIGH);
 delay(dtime);
 //top pin 0 off
 digitalWrite(groundpins[0], LOW);
 digitalWrite(ledpins[0], LOW);
 delay(dtime);
 //bottom pin 1 on
 digitalWrite(groundpins[1], HIGH);
 digitalWrite(ledpins[1], HIGH);
 delay(dtime);
 //bottom pin 1 off
 digitalWrite(groundpins[1], LOW);
 digitalWrite(ledpins[1], LOW);
 //top pin 2 on
 digitalWrite(groundpins[0], HIGH);
 digitalWrite(ledpins[2], HIGH);
 delay(dtime);
 //top pin 2 off
 digitalWrite(groundpins[0], LOW);
 digitalWrite(ledpins[2], LOW);
  //bottom pin 3 on
 digitalWrite(groundpins[1], HIGH);
 digitalWrite(ledpins[3], HIGH);
 delay(dtime);
 //bottom pin 3 off
 digitalWrite(groundpins[1], LOW);
 digitalWrite(ledpins[3], LOW);
 
 }
3  Community / Exhibition / Gallery / Re: Nightlinght on: January 02, 2013, 09:23:06 pm
I built a "smart" night light with an ATtiny85 and a motion sensor hacked from an air freshener.  It is normally PWM LED at a dim level.  If it "sees" you, it goes full bright.  After 30 seconds of not "seeing" anyone, it goes to a dim level again.

That's a cool idea too. I need to get a bunch of bread boards so I can make these little projects and set them aside for later rather than pulling them apart each time.
4  Community / Exhibition / Gallery / Re: Nightlinght on: December 31, 2012, 02:17:50 pm
Thanks. I'm petty new to all of this so I'm trying to start out slowly. I would like to keep expanding the project though. I'm thinking a push button may be the next thing to implement.
5  Community / Exhibition / Gallery / Nightlinght on: December 30, 2012, 09:53:31 pm
I'm sure others have done this, but I made a night light with a photo resistor and some nice white LEDs that I have. It works pretty well. Here is the code and a short video of it.

Code:

int lightPin = 0; //Photo resistor analog read pin
int ledPin1 = 13;   //the pins the LEDs are connected to
int ledPin2 = 12;
int ledPin3 = 11;
int ledPin4 = 10;
int ledPin5 = 9;
int ledPin6 = 8;
int ledPin7 = 7;
int ledPin8 = 6;
int ledPin9 = 5;
int ledPin10 = 4;
  
void setup()
{
  pinMode(ledPin1, OUTPUT); //sets the led pin to outputs
  pinMode(ledPin2, OUTPUT);
  pinMode(ledPin3, OUTPUT);
  pinMode(ledPin4, OUTPUT);
  pinMode(ledPin5, OUTPUT);
  pinMode(ledPin6, OUTPUT);
  pinMode(ledPin7, OUTPUT);
  pinMode(ledPin8, OUTPUT);
  pinMode(ledPin9, OUTPUT);
  pinMode(ledPin10, OUTPUT);
  
Serial.begin(9600); //Sets the baud rate for the serial read
}
 
void loop()
{
 int lightLevel = analogRead(lightPin); //Read the light pin
                                      
 Serial.println(lightLevel); delay(1000);//print light pin and delay time


  if(analogRead(lightPin) < 650){ //if light pin is above 650 lights off
    digitalWrite(ledPin1, HIGH); //note that you can adjust the value
    digitalWrite(ledPin2, HIGH);// so that it fits your needs
    digitalWrite(ledPin3, HIGH);
    digitalWrite(ledPin4, HIGH);
    digitalWrite(ledPin5, HIGH);
    digitalWrite(ledPin6, HIGH);
    digitalWrite(ledPin7, HIGH);
    digitalWrite(ledPin8, HIGH);
    digitalWrite(ledPin9, HIGH);
    digitalWrite(ledPin10, HIGH);
  }else{ //otherwise
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
   digitalWrite(ledPin3, LOW);
  digitalWrite(ledPin4, LOW);
 digitalWrite(ledPin5, LOW);
digitalWrite(ledPin6, LOW);
digitalWrite(ledPin7, LOW);
digitalWrite(ledPin8, LOW);
digitalWrite(ledPin9, LOW);
digitalWrite(ledPin10, LOW);

  }
}

 
 

http://youtu.be/UElvIOkMpv8
Pages: [1]