Reading analog input into binaray array


Im wanting to read a value from the analog inputs for 0-1024 and convert it to binaray and then be able to read this and make a pin go high or low depending on wether it is a 0 or 1 with a delay between each bit

Im wanting to

You have permission, you don’t need to ask.

read a value from the analog inputs for 0-1024

That would be an eleven-bit conversion.
You meant 1023, I assume.

int val = analogRead(aPin);
for(byte i = 0; i < 10; i++){
  digitalWrite(dPin, (val & (1 << i)) != 0);

Umm, I assume this is what you wanted?

If this doesn’t work, you get what you pay for. You have to comment it yourself.

int sensorPin = A0;
int ledPin = 13;
int sensorValue;

const int analogRange = 1024;
int shiftMask;

void setup() {
  pinMode(ledPin, OUTPUT);  

void loop() {
  sensorValue = analogRead(sensorPin);    
  for (shiftMask=1; shiftMask<analogRange; shiftMask<<1)
  digitalWrite(ledPin, sensorValue & shiftMask);  
  digitalWrite(ledPin, LOW);


should be

shiftMask<<=1) ?


should be

shiftMask<<=1) ?