Hello there. Sorry for my bad language.
when i readanaloge values from a potentiometer using arduino nano in proteus simulation, it always gives me the full range of ADC 1023, no matter what is the input(GND,5v,or in between). I tried using arduino uno with the same code its works very will.
transmitter code:
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
RH_ASK driver;
void setup(){
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}
void loop(){
char temp[2];
int Direction=analogRead(A0);// int size 2 bytes
Serial.println(Direction);
delay(200);
byte lowerByte = (Direction & 0xFF); // gives you the right hand 8 bits// one byte
byte upperByte=(Direction >>8);// another one byte(the left hand byte.
temp[0]=lowerByte;
temp[1]=upperByte;
driver.send((uint8_t *) temp, sizeof(temp));
driver.waitPacketSent(); // Wait until the whole message is gone
}
receiver code:
#include <RH_ASK.h>
#include <SPI.h> // Not actualy used but needed to compile
RH_ASK driver;
void setup(){
Serial.begin(9600); // Debugging only
if (!driver.init())
Serial.println("init failed");
}
void loop(){
uint8_t buf[2];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen)) // Non-blocking
{
int analogue;
analogue=(buf[1]<<8)|buf[0];
Serial.println(analogue);
delay(200);
}
}
Proteus connection:
