Show Posts
Pages: [1]
1  Using Arduino / Sensors / Re: Infrared Reflectance Sensor on: January 18, 2013, 05:32:03 pm
Code:
int aval1 =0;
int aval2 = 0;
int avalr = 0;
int refval = 0;
int pwm=0;
int bias=0;
int t=0;
char* str1[] = {"CHANNEL A", "CHANNEL B", "CHANNEL C"};
int lf = 0;
int rg = 0;
int st = 0;
void setup()
{
// Print a message to the LCD.
//lcd.print(str1[st]);
//lcd.print(analogRead(0));
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
digitalWrite(5,LOW);
digitalWrite(4,HIGH);
Serial.begin(9600);
bias = 40;
}
void loop()
{
st = 0;
aval1 = 0;
aval2 = 0;
digitalWrite(7,HIGH);
analogWrite(9,255);
analogWrite(10,255);
while (st < 10)
{
st++;
digitalWrite(7,HIGH);
delayMicroseconds(10);
aval1 = aval1+analogRead(0);
digitalWrite(7,LOW);
delayMicroseconds(10);
aval2 = aval2+analogRead(0);
}
//refval = analogRead(1);
refval = 20;
Serial.print(aval2-aval1);
avalr = aval2-aval1;
Serial.print("<");
Serial.print(avalr);
Serial.print(">");
if (abs(aval2-aval1)>refval)
{
digitalWrite(5,HIGH);
pwm = 50;
analogWrite(9,255);
analogWrite(10,pwm+bias);

}
else
{
digitalWrite(5,LOW);
pwm = 50;
analogWrite(9,pwm);
analogWrite(10,pwm+bias);
}
//lcd.clear();
//lcd.print(str1[0]);
//lcd.setCursor(1,1);
//lcd.print("Analog=");
//lcd.print(aval2-aval1);
//lcd.print(" : ");
//lcd.print(refval);
delay(500);
}

This is the code they sent me... It seems a little bit wrong because they defining 6 pins to output, but the schematic just shows 5 to connect to the digital ports... This code just gives me -2, -1, 0, 3... Whats wrong here? I can't figure out why this isn't working...

Then I coded this myself: (I think this is also wrong)

Code:
void setup() {
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
Serial.begin(9600);
}

void loop() {
  int myInts[5];
  int pin = 5;
  for (int i = 0; i < 5; i++) {
    digitalWrite(pin, LOW);
    int var = analogRead(0);
    myInts[i]=var;
    pin++;
    delay(100);
  }
  int i;
  for (i = 0; i < 5; i = i + 1) {
  if(myInts[i] == 843){
    Serial.println("Weiss");
  } else {
    Serial.println("Schwarz");
}
  }
  Serial.println("---------------");
}
2  Using Arduino / Sensors / Re: Infrared Reflectance Sensor on: January 12, 2013, 05:37:58 pm
The problem is the value doesn't even change... I think my code might be wrong! I set all the digital pins to output. I check the LEDs they are a lit up. Then I analogRead Pin 0. Value stays 844, 844, sometimes 843. I can do anything I want, I used white paper, black paper, LCD screens (for reflecting) the value doesn't change.

I really want to get this to work!
3  Using Arduino / Sensors / Infrared Reflectance Sensor on: January 09, 2013, 04:41:55 pm
Hello I want to build a line follower so I bought one of this http://www.ebay.at/itm/270589619744?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649#ht_3121wt_802

I have made some projects before, but this is the first time using a sensor... So I soldered it together an connected pin1 and pin2 to 5V and GND, pin3 to AnalogIn 0. I connected the other pins to digital. I tried around with pinOut to the digital pins and checked the LEDs with a camera. They all work. Now here comes the tricky part: I used analog read(A0) but it just gives me 843 or 842 on the Serial Monitor...? What am I doing wrong? Can somebody help me please?

Thanks a lot!
4  Using Arduino / LEDs and Multiplexing / Re: Control a 8x8 RGB LED Matrix on: February 07, 2012, 05:09:39 am
I've got one Shift Register at home but I think it's really complicated to do it that way... Couldn't I control it with a Colorduino? It got enough pins for the RGB Matrix, but I need the code to control each LED separately..

Thanks
5  Using Arduino / LEDs and Multiplexing / Control a 8x8 RGB LED Matrix on: February 06, 2012, 02:16:21 pm
I want to control my 8x8 RGB Matrix so I can turn on/off specific LEDs and change their color. My Matrix has 16 Pins on each site, so total 32. I've got an Arduino Uno + a Colors Shield. The plasma-example works great, and I know how to fill the Matrix. Can someone please give me an example like displaying "HELLO" (each letter separately?), and changing the color? It would also be great if you guys could show me how I can get this to work: http://arduino.cc/playground/Main/DirectDriveLEDMatrix (Life + Hello)

Thanks a lot!
Pages: [1]