Go Down

Topic: Flex Sensor and Mini 8X8 LED Matrix???? (Read 5403 times) previous topic - next topic

bandrake


You could have these act as buffers for the Arduino pins if you wanted to crank the current up thru the LEDs some more, or if you wanted to one arduino pin drive several LEDs in parallel.


Let's do it-if you can explain simply for my dumb self hah.  I have 9 LEDs going from pins 3 to 11 each with a 330R.
Flex sensor is running a 10K resistor and is hooked up to A0. It works! thanks again.

Down to try and make brighter/better.  These MOSFETS are not compact though :/ already having trouble fitting the arduino in my model but may be able to pull it off.  Either way we have it figured out already so if can improve will try.

FINAL CODE BELOW

Code: [Select]

int pin1 = 3;
int pin2 = 4;
int pin3 = 5;
int pin4 = 6;
int pin5 = 7;
int pin6 = 8;
int pin7 = 9;
int pin8 = 10;
int pin9 = 11;

void setup() {
   pinMode(pin1,OUTPUT);
   pinMode(pin2,OUTPUT);
   pinMode(pin3,OUTPUT);
   pinMode(pin4,OUTPUT);
   pinMode(pin5,OUTPUT);
   pinMode(pin6,OUTPUT);
   pinMode(pin7,OUTPUT);
   pinMode(pin8,OUTPUT);
   pinMode(pin9,OUTPUT);
   Serial.begin(9600);
}

void loop(){
  int sensorValue = analogRead(A0);
  Serial.println(sensorValue);
    if(sensorValue <= 390){
    digitalWrite(pin1,HIGH);
  } else {
    digitalWrite(pin1,LOW);
  }
  if(sensorValue <= 410){
    digitalWrite(pin2,HIGH);
  } else {
    digitalWrite(pin2,LOW);
  }
    if(sensorValue <= 420){
    digitalWrite(pin3,HIGH);
  } else {
    digitalWrite(pin3,LOW);
  }
  if(sensorValue <= 430){
    digitalWrite(pin4,HIGH);
  } else {
    digitalWrite(pin4,LOW);
  }
  if(sensorValue <= 450){
    digitalWrite(pin5,HIGH);
  } else {
    digitalWrite(pin5,LOW);
  }
  if(sensorValue <= 475){
    digitalWrite(pin6,HIGH);
  } else {
    digitalWrite(pin6,LOW);
  }
    if(sensorValue <= 500){
    digitalWrite(pin7,HIGH);
  } else {
    digitalWrite(pin7,LOW);
  }
  if(sensorValue <= 510){
    digitalWrite(pin8,HIGH);
  } else {
    digitalWrite(pin8,LOW);
  }
  if(sensorValue <= 520){
    digitalWrite(pin9,HIGH);
  } else {
    digitalWrite(pin9,LOW);
  }
}

Go Up