# Picaxe 14m2 Ouestion?

#### skyhorse33

Joined Jan 5, 2012
15
Picaxe 14m2 Ouestion? The only picaxe I have used is the 08m2. I have a PCB control board for a camera. The board senses motion and triggers the camera to take a picture or a video whichever it is set on. All the pins on the 08m2 are used except 2. But it already has a 10k to ground on it because I have a programmer on each board. I need another out pin so I have to step up to a 14m2. No need to go larger plus I cannot fit a larger board in my case. My question is can I leave the unused pins floating or should I tie them to ground with a resistor?

B-0 1k to Opto to power Camera

B-1 1k to Opto to shutter Camera

B-2 Led for walk test

B-3 to turn on infrared Array for night videos

B-4 Not Used

B-5 Not Used

C-5 Not Used Is a In – Used in Programming

C-4 Out to Read LDR light dependent resistor

C-3 PIR sensed motion triggers camera

C-2 Not Used

C-1 Not Used

C-0 Not Used

#### Attachments

• 49.7 KB Views: 4

#### nerdegutta

Joined Dec 15, 2009
2,676
Hi.

I think this is not a specific PICAXE 14m2 question, but rather a microcontroller question. There a several ways to deal with unused PINs.
• Leave them floating. Not good practice. You can get strange circuit behaviour.
• Leave them floating and program them to output, and put them high or low.
• Tie them to Vdd with a resistor.
• Tie them to Vdd with a resistor, and program them to input and high.
• Tie them to Vss with a resistor.
• Tie them to Vss with a resistor, and program them them to output and low.
... and my favourite: Tie them to a test pad, and program them to output and set them low. If I for some reason needs to add another sensor or gadget on my circuit, the pad is already there, and I just need to change the software.

#### skyhorse33

Joined Jan 5, 2012
15
Thanks for replying and for your answer. One question for use in this program do you think I would be OK if I left them floating and program them to output and put them low? If I tied to a test pad or used the resistors I would most likely have to enlarge the board. This I am trying to avoid because of the placement in the case not much room. I have already purchase the case for this project. I like the idea of the tying to test board for use later because I could put a slave flash on the unit later. For this I could enlarge the board and order a large case. I may have to come back and ask how to build the test board.
Skyhorse

#### Roderick Young

Joined Feb 22, 2015
408
In the 14M2, or any PICAXE in general, the only pins you must have connected are Vdd, Ground, and the serial programming input. Any others may be left floating, even if they are inputs. At the beginning of your program, use the PULLUP statement to specify internal pullup resistors for those unconnected pins. If you program the pins as outputs, that will work, too, but I prefer not to drive an output that is not going anywhere, personally. As to what happens if the pins are left as inputs with no internal pullup, that's probably ok, as the pins generally can be configured as analog A/D, anyway, but again, I prefer to use the PULLUP statement, as it costs nothing.

One tip if you're making a PC board and have the space, would be to bring out those unused pins to uncommitted pads. Then later, if you change your mind and want to use one of those extra pins, it will be easy to wire in.

Last edited:

#### skyhorse33

Joined Jan 5, 2012
15
Thank You for the explanation on the unused pins and how to place the unused pin on an uncommitted pad. I have never used the pull-up statement before. Could you explain how to put this in my program or would I just put, Disable internal pull-up resistor on pin 5?

#### skyhorse33

Joined Jan 5, 2012
15
Thank You, but I was hoping for a example in a program code.

#### Roderick Young

Joined Feb 22, 2015
408
The link OBW gave above pretty much is code, but here is a little more

Code:
#picaxe 14M2

pullup %0001100000000000    ; C.4, C.3 used as inputs
dirsC = %00000000
dirsB = %00000010
This was snipped from a program where C.4 and C.3 were external digital inputs coming from pushbutton switches. Other pins were either analog inputs or outputs.

#### skyhorse33

Joined Jan 5, 2012
15
OK if I follow you correctly my code should start like this.

'14M2 Pin Out

'B.0 camera power

'B.1 shudder

'B.2 led

'B.3 to array

'B.4 not used

'B.5 not used

'C.0 not used

'C.1 not used

'C.2 not used

'C.3 pir

'C.4 ldr

'C.5 program

'SETTING INPUTS/OUTPUTS

output b.0

output b.1

output b.2

output b.3

output b.4 pullup %0001100000000000

output b.5 pullup %0001100000000000

output c.0 pullup %0001100000000000

output c.1 pullup %0001100000000000

output c.2 pullup %0001100000000000

input c.3

output c.4

input c.5

#### Roderick Young

Joined Feb 22, 2015
408
If you're going to set unused pins as outputs, you will not need the PULLUP statements. This is all you need:
Code:
output b.0
output b.1
output b.2
output b.3
output b.4
output b.5
output c.0
output c.1
output c.2
input c.3
output c.4
input c.5
But if you use the dirsB and dirsC command, you can set all inputs and outputs in just a couple lines. Look at the PICAXE manual, under System Variables. The dirsB register has bits set up like this:
b5 : b4 : b3 : b2 : b1 : b0
and you put a '1' in the binary position for any pin that you want to set as an output. In your case, those are all outputs, so the value you want is
1 : 1 : 1 : 1 : 1 : 1 or for the compiler, %111111 (you could also use the decimal number 63, but that's less descriptive)
for the dirsC, you want c.3 and c.5 to be inputs, so put a '0' in each of those positions, and a '1' in all the others:
0 : 1 : 0 : 1 : 1: 1 or %010111 for the compiler.

In summary, the code looks like this:
Code:
    dirsB = %111111
dirsC = %010111
That is all you need. If you wanted to use the other method and set the unused pins to have pullups, all you would need is a single line at the beginning of your program, not the pullup statement following every output declaration. Again, you don't need that if you go with setting the unused to outputs, so I'll leave that as an exercise to you. It's in the manual, and you set the bits in a very similar manner, each one corresponding to an output pin.

#### skyhorse33

Joined Jan 5, 2012
15
Roderick, Thank You very much for taking time and explaining this for me. I am in my 70's and my memory is not what it used to be. I have to make notes, lots of them. But I am thankful and grateful for what I do have and for people like you helping some one like me. I can read the manual and a week later I have to go back and reread what I have read. I have done very little programming and I just cannot seem to grasp the % codes with all the numbers. I enjoy making these control boards that control a camera. Programming is just not one of my gifts. So Thanks again......Skyhorse

#### skyhorse33

Joined Jan 5, 2012
15
It appears that the order you started in for dirsC is c.5 to c.0. Is the correct?

#### Roderick Young

Joined Feb 22, 2015
408
It appears that the order you started in for dirsC is c.5 to c.0. Is the correct?
Yes, if you're reading left to right. The % sign has no magic behind it. It just denotes that the number following will be in binary.

#### skyhorse33

Joined Jan 5, 2012
15
Thank You Roderick and all other that helped out. I feel quite sure I have my code worked out and now I need to finish my board put all to work. I will be testing in a few days and try to report results.

#### ISB123

Joined May 21, 2014
1,236
You can post it in completed projects when its finished but you have to write a small guide on how you constructed it.

Last edited: