Thread: How to read the binary value of an analo

  1. #1
    Registered User
    Join Date
    Aug 2018
    Posts
    7

    How to read the binary value of an analogue input pin

    Hi I'm trying to write a small piece of code that that reads the input from an analogue pin every second. I just don't know what the code is to get the binary input string. Any help would be great, my code is below:

    Code:
    int sensorValue = 0;
     
    void setup() {
     Serial.begin(9600); 
     ADMUX = B01000000;
     ADCSRB = B00000000;
    }
     
    void loop() {
     sensorValue = ADCSRB; //Read Analogue Input ????
     Serial.print("Sensor = " ); 
     Serial.print(sensorValue); 
     delay(1000); 
    }
    Last edited by ALB10811Banner; 09-20-2018 at 01:07 AM.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2018
    Posts
    7
    Thanks, I got it working

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How to read binary img file
    By c_weed in forum C++ Programming
    Replies: 11
    Last Post: 11-27-2014, 12:24 PM
  2. Binary file read
    By BIGDENIRO in forum C Programming
    Replies: 4
    Last Post: 11-18-2013, 10:25 AM
  3. Read binary, change a value, write to binary
    By mammoth in forum C Programming
    Replies: 16
    Last Post: 05-12-2011, 10:56 AM
  4. Read binary files
    By nime in forum C Programming
    Replies: 25
    Last Post: 01-17-2011, 02:54 AM
  5. Read a binary file
    By Sue Paterniti in forum C Programming
    Replies: 8
    Last Post: 04-29-2002, 02:36 AM

Tags for this Thread