Arduino Uno Analog Sensor Control Code

Analog Sensors can sense multiple analog signals and convert them to digital numbers with the help of an integrated ADC converter. ADC converters are analog to digital converters. You can learn more about ADC conversion on the internet. You can use or analyze these digital numbers later on. 0 to 5V is represented by numbers from 0 to 1023. You can read multiple sensors by adding multiple analog pins to your programcode.

arduino uno with analog sensor
Figure 1 - Arduino Uno with Analog sensor

Required hardware

  • Arduino Uno
  • Analog sensor

Source code to install on controller


Before you upload this code to your Arduino, please format the EEPROM...

Analog Sensor Arduino

#include <OzIDManager.h>
#include <OzAnalogSensor.h>
				
OzIDManager* manager;
OzAnalogSensor* analogSensor;

void setup() 
{
  Serial.begin(115200);

  manager = new OzIDManager;
  manager->_sendACK = true;
  manager->_checksum = true;

  OzCommunication::setIDManager(manager);

  analogSensor = new OzAnalogSensor(A5);
  analogSensor->reset();

  int x=1;
  manager->sendLinkSetup();
  manager->PrintWelcomeLine(analogSensor, x++, "MyAnalogSensor");
}

void loop()
{
  OzCommunication::communicate();
  analogSensor->ownLoop();
}

More information