#include "SoftwareSerial.h" // Declare and initialize UART pins const int rx_pin = 4; const int tx_pin = 5; // Declare and initialize hall sensor pin const int hall_pin = 8; // Create new serial with specified UART pins SoftwareSerial mySerial(rx_pin , tx_pin); void setup(){ // Set the pin modes of UART pins pinMode(rx_pin, INPUT); // Receiving requires input pinMode(tx_pin, OUTPUT); // Transmitting requires output // Set sensor as input pinMode(hall_pin, INPUT); // Start the serial communication at 9600 bits/sec mySerial.begin(9600); } void loop(){ // Read the analog value of the pin and send it via serial communication int val = analogRead(hall_pin); mySerial.println(val); // Add a small pause of 50ms delay(50); }