Go Down

Topic: Can I set digitalWrite other than analog and digital pins? (Read 384 times) previous topic - next topic

jepoy12

Mar 05, 2013, 12:07 am Last Edit: Mar 05, 2013, 12:49 am by jepoy12 Reason: 1
I want to set the pinMode to a specific pin like in the pin 29 of atmega32. Can I do that?

MarkT

ATmega32 ??   Do you mean ATmega328 or ATmega32U4 ?

Basically pinMode works with pins that are defined via the pins_arduino.h file for the relevant variant.
[ I won't respond to messages, use the forum please ]

Grumpy_Mike

Don't understand what you are asking.
But the pin mode can be set as an input r output for any pin on the arduino

jepoy12

#3
Mar 05, 2013, 12:46 am Last Edit: Mar 05, 2013, 12:48 am by jepoy12 Reason: 1
Sorry Im not good at explaining. its Atmega328
heres what Im planing.

Code: [Select]
int reset= 29;                 // pin no. of atmega328 which is the reset

void setup()
{
 pinMode(reset, OUTPUT);      // set reset as output
}


 digitalWrite(reset, low);   // use it when I want to reset the atmega328



I think digitalWrite is for analog and digital only.

retrolefty


Sorry Im not good at explaining. its Atmega328
heres what Im planing.

Code: [Select]
int reset= 29;                 // pin no. of atmega328 which is the reset

void setup()
{
 pinMode(reset, OUTPUT);      // set reset as output
}


 digitalWrite(reset, low);   // use it when I want to reset the atmega328



I think digitalWrite is for analog and digital only.


You can't do what you are trying to do. The reset pin on a 328P can be set with fuse settings to be either the hardware reset signal for the chip or a general purpose I/O pin, it can't be used for both purposes. If fuses are set to use the reset pin as an I/O you lose the ability to program the chip via bootloader or ISP method so that pin is always used as a hardware reset pin only for any arduino IDE compatible board, and you have no program control over it.

If you want to be able to reset the chip while it's running your sketch, read up on using the watch dog time (WDT), it's easy to do and is the only correct method to perform a chip reset without using external components.

Lefty


Go Up