pinMode(leftJS, INPUT); // let Arduino know that this is an input pinMode(rightJS, INPUT); // let Arduino know that this is an input pinMode(gripJS, INPUT); // let Arduino know that this is an input
int leftPOS = 90; // initialize left wheel position variable to 90 degreesint rightPOS = 90; // initialize right wheel position variable to 90 degreesint gripPOS = 90; // intitialize gripper position variable to 90 degrees
I am wondering how do i combine the two ?!?!
Analog pins are INPUT only
but the analog pins are NOT input-only.
Quotebut the analog pins are NOT input-only.They are so. The analog pin can NOT be used to output anything. Now, get over it!
Details and CaveatsThe analogRead command will not work correctly if a pin has been previously set to an output, so if this is the case, set it back to an input before using analogRead. Similarly if the pin has been set to HIGH as an output, the pullup resistor will be set, when switched back to an input.The Atmega datasheet also cautions against switching analog pins in close temporal proximity to making A/D readings (analogRead) on other analog pins. This can cause electrical noise and introduce jitter in the analog system. It may be desirable, after manipulating analog pins (in digital mode), to add a short delay before using analogRead() to read other analog pins.
Analog pins are INPUT only, so this is useless.
Did both sections of code work ok on their own?
They are so. The analog pin can NOT be used to output anything. Now, get over it!
pinMode(A0, OUTPUT);digitalWrite(A0, HIGH);
The analog pins certainly can be used as digital inputs and outputs.
Yes but then they are not analogue pins they are digital pins.
Saying that the analog input pins can't be used for digital I/O doesn't make sense - they plainly can.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16