Hi,
I understand that the internal arduino pull up (down) resisters can be set by adding a few lines of C code, but cant find the relevant C code, could someone please give an explanation or examples of how to set them please?
Regards,
Chris
Seting Arduino pull up / down resisters
-
- Posts: 186
- Joined: Wed Jan 23, 2013 3:43 pm
- Has thanked: 2 times
- Been thanked: 21 times
- Contact:
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Seting Arduino pull up / down resisters
Hi Chris,
There's just internal pull up resistors on the Mega328P no pull down.
Here is some code you can use to add pull ups to port pin B0, other port pins work in the same way. Basically the pin has to be configured as an input and then you set the bits in the port register, the order doesn't seem to matter according to the datasheet.
There's just internal pull up resistors on the Mega328P no pull down.
Here is some code you can use to add pull ups to port pin B0, other port pins work in the same way. Basically the pin has to be configured as an input and then you set the bits in the port register, the order doesn't seem to matter according to the datasheet.
Code: Select all
MCUCR &= 0xEF; //Global Enable Pull Ups - Clear PUD bit
DDRB |= 0x01; //Port pin B0 configured as input
PORTB |= 0x01; //Pull up enable
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel