Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

SimulIDE_0.4.15-SR10 ATTiny85 always reading zero volts

2 posters

Go down  Message [Page 1 of 1]

eugenet



  • Potentiometer connected to pin PB5.
  • analogRead(PB5) always return a zero.
  • Sample program below demonstrates the problem.


If analogRead is zero, It turns on LED on pin PB0. Otherwise the LED on pin PB1 is turned on instead.
Code:
void setup() {
  pinMode(PB5, INPUT);
  DDRB |= (1 << PB0);  // Set pin PB0 for output
  DDRB |= (1 << PB1);  // Set pin PB1 for output
}

void loop() {
  if (analogRead(PB5)==0) {
    PORTB |= (1 << PB0);  // PB0 LED ON
    PORTB &= ~(1 << PB1); // PB1 LED OFF
  } else {
    PORTB &= ~(1 << PB0); // PB0 LED OFF
    PORTB |= (1 << PB1);  // PB1 LED ON
  }
}

SimulIDE_0.4.15-SR10 ATTiny85 always reading zero volts Image11

arcachofo

arcachofo

Hi.
I see a problem in your circuit:
10KOhm Potentiometer should be connected to ground, not to 100 Ohm resistor.

Another issue is analogRead(PB5).
I think you should use analogRead(0) or analogRead(A0).

If this does not solve the problem let me know.

eugenet



Thanks, that fixed the problem.  SimulIDE_0.4.15-SR10 ATTiny85 always reading zero volts 1f44d

arcachofo likes this post

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum