I moved my SoftSerial tx_pin from 6 (PORTD,5) to 11 (PORTB,2). All I get is gibberish on the LCD. Has anybody else had problems with SoftSerial on portb?
This is the craziest thing. I moved the txpin and applied the following piece of code at the same time. I checked the pins are not cross defined.
void resetPot (void)
//
{
pinMode(INC,OUTPUT);
pinMode(POT_SELECT,OUTPUT);
pinMode(UD,OUTPUT);
digitalWrite(INC,HIGH);
digitalWrite(POT_SELECT,SELECT);
digitalWrite(UD,DOWN);
for(char i=0;i++;i<100)
{
digitalWrite(INC, HIGH); // sets the pin on
//delayMicroseconds(50); // pauses for 50 microseconds
digitalWrite(INC, LOW); // sets the pin off
// delayMicroseconds(50); // pauses for 50 microseconds
}
digitalWrite(INC,HIGH);
digitalWrite(POT_SELECT,HIGH);
delay(20);
}
Note I commented the delayMicroseconds(50) statements out. This way the code work. If I include them the gibberish on the LCD is actually a crashed state. Any takers?
If I use delay() it is ok. Any suggestions please?
Can you post all the code, often problems are elsewhere, for example
digitalWrite(UD,DOWN);
makes no sense in the above context because "DOWN" is not a standard symbol, maybe it's been defined somewhere else and maybe that definition was incorrect.
Rob
Marius:
This is the craziest thing.
Don't know about other crazy things, and can't say whether this contributes to any problems you are experiencing, but the following loop is never entered:
for(char i=0;i++;i<100)
{
// Never gets here. Really. Never.
}
Regards,
Dave
AWOL:
Never, ever?You sure?
Yes.
Regards,
Dave
for(char i=0;i++;i<100)
The second "term" is the termination (continuation, more like) condition. It's zero the first time through the loop, so the loop doesn't do anything. You probably wanted for(char i=0;i<100; i++)
Rob,
Sorry for the long delay. I took some time off.
These are the defines. The rest of the code is a lot and mostly belongs to the party I am writing it for. Don't know if it is right to post it?
// POT
#define POT_SELECT 6
#define INC 1
#define UD 5
// Pot
#define UP 1
#define DOWN 0
#define SELECT 0
#define UNSELECT 1
Dave,
You found the problem. This is what you get when you still sit and code at 2 in the morning.
Thanks gents- sorted out.