Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

A0 Powering ProMicro

Status
Not open for further replies.

ibwev

Member
I am using a knock-off 5 volt ProMicro https://www.banggood.com/Wholesale-...ompatible-Nano-Size-p-68534.html?rmmds=search . I am trying to send a value to an output pin depending on which of three input pins (A0,A1,A2) is receiving a digital 5 volt input signal. I would like to poll the input pins once power is supplied to the raw input of the ProMicro. When I supply power to any one of the three input pins without supplying power to the raw pin, the ProMicro activates and runs the program. I am using the following code with A0 as my only input to troubleshoot the issue:

Code:
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(A0, INPUT);
}

// the loop function runs over and over again forever
void loop() {
  if(A0, HIGH)
  {
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(1000);                       // wait for a second
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    delay(2000); 
  }// wait for a second
 else
 {
    digitalWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    delay(20);                       // wait for a second
    digitalWrite(LED_BUILTIN, HIGH);    // turn the LED off by making the voltage LOW
    delay(2000);
   }
}

Should I expect the ProMicro to activate without supplying power to raw and any or all of A0, A1, A2 is set to high?

If so, is there a way to only power the ProMicro using the raw pin irregardless of whether or not A0, A1, and/or A2 is set high?
 
Your micro is being powered via the protection diodes on the input pins. To prevent this use 20k resistors in series with the 3 input signals and make sure there is some load across the supply - a 2k resistor will do.

Mike
 
use 20k resistors in series with the 3 input signals and make sure there is some load across the supply - a 2k resistor will do

Thank you for the reply. Does this schematic follow your suggestion?
BackFeedQuestion.jpg
 
You don't need the 2ks to ground but do need something to "use" the tiny current supplied by the 20ks. An LED and resistor on the power lines would be ideal. If not one 2k resistor across the power lines will suffice.

Mike.
 
If not one 2k resistor across the power lines will suffice.

Is this correct?
BackFeedQuestion.jpg


Am I correct in understanding the above circuit reduces the flow of current to a manageable level by use of the 20K resistors. If raw is at 0 volts and and a combination of switches are closed then the current allowed in the ProMicro goes through the protection diodes and is converted to heat in the 2K resistor; thereby, not allowing the ProMicro to activate?
 
That is correct. If all 3 switches are closed then it will form a voltage divider with a 4 to 1 ration (6.6k and 2k) and so the micro will only see 1.25V and will not turn on.

Mike.
 
I have connected everything as shown in Post 5. When 4.9 V is supplied to a closed switch and 0V to the ProMicro, I am getting about 2.1 V to the pin on the ProMicro. However, when I supply 8.8 V to raw on the ProMicro with the switch closed, I get a voltage reading of 0 V from A0 (same is true for A1, and A2 ) to ground.

In an attempt to get it to work, I have altered the code a little from Post 1.

Code:
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  analogWrite(A0, LOW);  //set internal pull-down resistor
  analogWrite(A1, LOW);
  analogWrite(A2, LOW);
 
 
}

// the loop function runs over and over again forever
void loop() {
  if(A0 > 2.5  and A1 < 2.5 and A2 < 2.5)
  {
    analogWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(500);                       // wait for a second
    analogWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    delay(2500);
  }// wait for a second
 else if(A0 > 2.5  and A1 > 2.5 and A2 < 2.5)
 {
    analogWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(500); // wait for a second
    analogWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    delay(500); // wait for a second
    analogWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(500); // wait for a second
    analogWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage 2.5
    delay(2000);
   }
  else if(A0 > 2.5  and A1 > 2.5 and A2 > 2.5)
 {
    analogWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(500); // wait for a second
    analogWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    delay(500); // wait for a second
    analogWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(500); // wait for a second
    analogWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    delay(500); // wait for a second
    analogWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(500); // wait for a second
    analogWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    delay(2000); // wait for a second
   }
     else if(A0 < 2.5  and A1 < 2.5 and A2 < 2.5)
 {
    analogWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(20); // wait for a second
    analogWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
    delay(2000); // wait for a second

   }
  
}

Please help me understand why there does not exist a voltage difference with respect to ground when the raw pin of the ProMicro is energized and the switch is closed. When the above code is executed and initialization is complete, the LED_BUILTIN remains low.
 
What is raw? Is it the supply to the micro? If so, shouldn't it be 5v? Why are you using analogue i/o? Does the micro still turn on without power applied or is this a new problem?

Mike
 
What is raw? Is it the supply to the micro?
Raw is the supply to the micro. "RAW is the unregulated voltage input for the Pro Micro. If the board is powered via USB, the voltage at this pin will be about 4.8V (USB’s 5V minus a schottkey diode drop). On the other hand, if the board is powered externally, through this pin, the applied voltage can be up to 12V"https://learn.sparkfun.com/tutorials/pro-micro--fio-v3-hookup-guide

Why are you using analogue i/o?
I have a reason but it is not a good one. I am using analogue i/o because it's location was convenient on the PCB board layout. I don't need any of the pins on the other side of the ProMicro so to save PCB space, I thought I would try to use the analogue i/o.

Does the micro still turn on without power applied or is this a new problem?
Your solution in Post #4 stopped the micro from turning on without power applied.
 
If you look at This Page and scroll down to I/O pins, you will see that all pins can be set to digital input and that only some pins can do analogue output (via PWM). Which port pin is the LED connected to?

Mike.
 
Note that you can use TXLED1 to turn the TX LED on and TXLED0 to turn it off.

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top