12.07.2015 Views

PICAXE Manual Section 1 - TechnoPujades - Free

PICAXE Manual Section 1 - TechnoPujades - Free

PICAXE Manual Section 1 - TechnoPujades - Free

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

www.picaxe.co.uk<strong>Section</strong> 1 81GETTING STARTEDUsing portc as digital inputsThe portc pins C0, C1, C2 are, by default, configured as outputs. They canhowever be reconfigured as inputs, but you must ensure your hardware designallows for the fact that the pin will be an output upon powerup. A simple 1kresistor in series with the pin will normally resolve this issue.To make the pin an input you must use ‘let dirsc = ‘ as described above.The following syntax is used to test the input condition:if portC pin0 = 1 then jumpi.e. the additional keyword ‘portC’ is inserted after the ‘if’ command.to test if two (or more) portc inputs are onif portC pin0 = 1 AND pin1 = 1 then jumpto test if either of two (or more) portc inputs are onif portC pin0 = 1 OR pin1 = 1 then jumpNote the portc command is only required once after the ‘if’ command.It is not possible to test inputs on two different ports within the same if…thenstatement.It is not possible to access the portc pins with any other ‘input’ type commands(count, pulsin etc). Therefore these pins should be reserved as simple on/offswitches.Note that ‘dirsc’ uses the common BASIC notation 0 for input and 1 for output.Using portc as analogue inputsThree additional ADC pins, ADC1,2,3, are available AFTER the corresponding pinhas been converted to an input. You must ensure your hardware design allows forthe fact that the pin will be an output upon powerup. A simple 1k resistor inseries with the pin will normally resolve this issue.Using portc as pwm outputsC5 can be used with the pwmout command, but will make this pin an output.Pins C2-5 (hpwm A-D) can all be used with the hpwm command, but will alsomake the corresponding pins outputs.Special Note - Output Pin 0Pin 0 (leg 13) is used during the program download, but can also be used as anormal output once the download is complete. Therefore you must rememberthat your output device will rapidly switch on and off as the download takesplace (not a problem with simple outputs like LEDs, but could cause problemswith other devices such as motors).revolution(c) Revolution Education Ltd. Email: info@rev-ed.co.uk Web: www.rev-ed.co.ukVersion 6.9 07/2009All rights reserved.81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!