Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Pressure Sensor Hook Up and Code: Repeat on: June 03, 2011, 02:07:59 am
Code:
void setup()
{
  pinMode(REDLED, OUTPUT);   //tell Arduino LED is an output
  pinMode(GREENLED, OUTPUT);  //tell Arduino LED is an output
  pinMode(BLUELED, OUTPUT); //tell Arudino LED is an output
  //pinMode(POT1, INPUT);      //tell Arduino LED is an output
  Serial.begin(9600);
  Serial.print(brt);Serial.println(blueval);
 


}

I must not be doing the serial print correctly.
2  Using Arduino / Programming Questions / Re: Pressure Sensor Hook Up and Code: Repeat on: June 03, 2011, 01:59:22 am
Code:
#define REDLED 11  //
#define GREENLED 12  //
#define BLUELED 13  //
#define POT1 A0

int i = 0;  // We'll use this to count up and down
int brt = 0;  //pot value
int redval= 0;
int blueval = 0;
int greenval = 0;

void setup()
{
  pinMode(REDLED, OUTPUT);   //tell Arduino LED is an output
  pinMode(GREENLED, OUTPUT);  //tell Arduino LED is an output
  pinMode(BLUELED, OUTPUT); //tell Arudino LED is an output
  pinMode(POT1, INPUT);      //tell Arduino LED is an output
  Serial.begin(9600);
 


}

void loop(){
  brt = analogRead(POT1);
 
  Serial.print("Sensor reading");Serial.println(blueval);

  //blue def
  blueval=((1000-brt)/4); //
 
  //green def
  if((brt>=0)||(brt<500)){ //
    greenval=.5*brt; //
  }
  else{
    greenval=250-((brt-500)/2); //
  }
 
 
  //red def
  redval=.25*brt; //
 
 
 
  analogWrite(BLUELED, blueval);
  analogWrite(GREENLED, greenval);
  analogWrite(REDLED, redval);
  delay(10);
 
}
3  Using Arduino / Programming Questions / Re: Pressure Sensor Hook Up and Code: Repeat on: June 03, 2011, 01:54:25 am
blueval=((1000-brt)/4); //

I did this because I wanted a value of 250 when the pressure was low (say 0)--which is the lowest pressure.
4  Using Arduino / Programming Questions / Re: Pressure Sensor Hook Up and Code: Repeat on: June 03, 2011, 01:50:17 am
Serial.print("Sensor reading;");Serial.println(brt);

(brt)---what I am refering to as 'brightness', but basically the pmw.. (right?)

I'm a newbie, please forgive me.
5  Using Arduino / Programming Questions / Re: Pressure Sensor Hook Up and Code: Repeat on: June 03, 2011, 01:43:54 am
Should be roughly 250
6  Using Arduino / Programming Questions / Re: Pressure Sensor Hook Up and Code: Repeat on: June 03, 2011, 01:39:50 am
I am getting -5 from my serial monitor.


Comment:
brt =abs(brt*3);
----yes this was for a test, it's not in the code.

And what do you mean by what values am i sending to the LED's?
7  Using Arduino / Programming Questions / Pressure Sensor Hook Up and Code: Repeat on: June 03, 2011, 01:09:09 am
I have been having trouble getting my pressure sensor to work with RGB LED's. Basically the project is a pressure sensor made with conductive fabric and velostat that is hooked up to 10 RGB lED's

What I am trying to make happen is when the pressure is low, have the LED's to be BLUE, when the pressure is medium, the LEDs will be GREEN, and when the pressure is at it's highest range, have the LED's be RED.

I have been working with the code and hooking up the LED's, but I'm at a loss. This is my code and I have a breadboard with 10 RGB LED's connected to the 9, 10, 11 slots and my pressure sensor attached. I only get blue with this:

#define REDLED 9  // red @ 9
#define GREENLED 10  // green @10
#define BLUELED 11  // blue @ 11
#define POT1 A0 //pressure sensor

int i = 0;  // We'll use this to count up and down
int brt = 0;  //pot value
int redval= 0;
int blueval = 0;
int greenval = 0;

void setup()
{
  pinMode(REDLED, OUTPUT);   //tell Arduino LED is an output
  pinMode(GREENLED, OUTPUT);  //tell Arduino LED is an output
  pinMode(BLUELED, OUTPUT); //tell Arudino LED is an output
  pinMode(POT1, INPUT);      //tell Arduino LED is an output
  Serial.begin(9600);
  


}

void loop(){
  brt = abs(analogRead(POT1));
   // Serial.print("Sensor reading;");Serial.println(brt);
  //brt =abs((950-(brt-100)));
  brt =abs(brt*3);
  

  

 //blue def
  blueval=((1000-brt)/4); //
 
  
//green def
 if((brt>=0)||(brt<500)) //
   greenval=.2*brt;
 else{
   {
   greenval=250-((brt-500)/2); //
  }
}

 
//red def
  redval=.25*brt;

 
 
  
  analogWrite(BLUELED, blueval);
  analogWrite(GREENLED, greenval);
  analogWrite(REDLED, redval);
  delay(10);
}
8  Using Arduino / Programming Questions / Re: Help With pressure sensor controlling color fade on: May 27, 2011, 02:46:57 pm
No that is when I severely push on it to get it to those numbers.

Once I take the serial.print out of the loop the numbers change.
9  Using Arduino / Programming Questions / Re: Help With pressure sensor controlling color fade on: May 27, 2011, 02:32:00 pm
Okay I added that into my code and this is what I got:

Sensor reading;0             (this being no pressure)
Sensor reading;16
Sensor reading;3
Sensor reading;21
Sensor reading;19
Sensor reading;23
Sensor reading;22
Sensor reading;21
Sensor reading;22
Sensor reading;16
Sensor reading;0

And it's blue that consistently lights up, but I'm pretty sure they are wired correctly.
10  Using Arduino / Programming Questions / Re: Help With pressure sensor controlling color fade on: May 27, 2011, 01:40:37 pm
Thank you for catching my serial statement that was out of place.

When I originally tested my pressure sensor, it didn't seem to get above a 1000 range, so I set it from 0-1000. What I want the color to represent is the amount of pressure that is on the sensor, so I want blue to be in the range of light pressure, green to be the middle pressure color and red to be the one with the highest amount of pressure at the (1000) point.
In other words
at 0, blue=250;
at 500, green=250;
at 1000, red = 250;

But the LED is only giving me blue at this point.
11  Using Arduino / LEDs and Multiplexing / help with pressure sensor controlling color fade on: May 27, 2011, 01:15:55 pm
I am building a pressure sensor that controls RGB lED's. I want to be able to get a smooth transition from blue (light pressure) to green (medium pressure) up to red (highest pressure) and am having trouble with the code.

//main sketch for pressure sensor(POT1) controlling brightness of LED's


#define GREENLED 9  //
#define BLUELED 10  //
#define REDLED 11  //
#define POT1 A0

int brt = 0;  //pot value
int redval= 0;
int blueval = 0;
int greenval = 0;

void setup()
{
  pinMode(REDLED, OUTPUT);   //tell Arduino LED is an output
  pinMode(BLUELED, OUTPUT);  //tell Arduino LED is an output
  pinMode(GREENLED, OUTPUT); //tell Arudino LED is an output
  pinMode(POT1, INPUT);      //tell Arduino LED is an output

}

void loop(){
  brt = analogRead(POT1);
 
  Serial.begin(9600);
  Serial.print (blueval);

  //blue def
  blueval=((1000-brt)/4);
 
  //green def
  if((brt>=0)||(brt<500)){
    greenval=.5*brt;
  }
  else{
    greenval=250-((brt-500)/2);
  }
 
  //red def
  redval=.25*brt;
 
 
 
  analogWrite(BLUELED, blueval);
  analogWrite(GREENLED, greenval);
  analogWrite(REDLED, redval);
  delay(10);
}



Anyone out there who can help with this?
12  Using Arduino / Programming Questions / Help With pressure sensor controlling color fade on: May 27, 2011, 01:13:32 pm
I am building a pressure sensor that controls RGB lED's. I want to be able to get a smooth transition from blue (light pressure) to green (medium pressure) up to red (highest pressure) and am having trouble with the code.

//main sketch for pressure sensor(POT1) controlling brightness of LED's


#define GREENLED 9  //
#define BLUELED 10  //
#define REDLED 11  //
#define POT1 A0

int brt = 0;  //pot value
int redval= 0;
int blueval = 0;
int greenval = 0;

void setup()
{
  pinMode(REDLED, OUTPUT);   //tell Arduino LED is an output
  pinMode(BLUELED, OUTPUT);  //tell Arduino LED is an output
  pinMode(GREENLED, OUTPUT); //tell Arudino LED is an output
  pinMode(POT1, INPUT);      //tell Arduino LED is an output

}

void loop(){
  brt = analogRead(POT1);
  
  Serial.begin(9600);
  Serial.print (blueval);

  //blue def
  blueval=((1000-brt)/4);
  
  //green def
  if((brt>=0)||(brt<500)){
    greenval=.5*brt;
  }
  else{
    greenval=250-((brt-500)/2);
  }
  
  //red def
  redval=.25*brt;
  
 
  
  analogWrite(BLUELED, blueval);
  analogWrite(GREENLED, greenval);
  analogWrite(REDLED, redval);
  delay(10);
}



Anyone out there who can help with this?
Pages: [1]