Trying to read analog input bolt V3

Discussion in 'UDOO BOLT' started by sanyc, Dec 28, 2022.

  1. sanyc

    sanyc New Member

    Joined:
    Dec 28, 2022
    Messages:
    2
    Likes Received:
    0
    Hello,
    I am trying to read analog input from the arduino embedded board on the bolt v3 but I am having trouble reading the signal. The voltage arriving at the input works fine (measured with a multimeter) but there is a problem with the code apparently.
    Can someone verify the validity of the code and let me know if it looks correct?
    Thank you

    //
    int roboteqPin = 3;

    // actuator encoders
    int fL = A5; // frontLeft
    int bL = A4; // backLeft
    int fR = A3; // frontRight
    int bR = A2; // backRight

    // Initialize storing variables
    int f_L = 0;
    int b_L = 0;
    int f_R = 0;
    int b_R = 0;

    // endpoint signals
    int encIn_fL = 8;
    int encOut_fL = 9;

    void setup() {
    // put your setup code here, to run once:

    Serial.begin(9600);

    //pinMode(roboteqPin, OUTPUT);
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);
    pinMode(7, OUTPUT);
    pinMode(encIn_fL, INPUT);
    pinMode(encOut_fL, INPUT);
    }

    void loop() {

    //digitalWrite(roboteqPin, LOW); // set DO to switch on RoboteQ

    digitalWrite(6, LOW);

    digitalWrite(7, HIGH);

    b_L = analogRead(A4);
    float voltage = b_L * (5.0 / 1023.0);
    Serial.print("Bits:");
    Serial.print(b_L);
    Serial.print("\n");
    Serial.print("Voltage:");
    Serial.print(voltage);
    Serial.print("\n");
    }
     

Share This Page