Intellecta Technologies Pty Ltd

for PICAXE education, Roland CAM, Techsoft CAD, Intellecta control, Atmel, Arm and Microchip education

Using Switches

Control 7 has two switch connections that can be used in the program to change the flow of information depending on the state of the switches.

The switches are external to the connector and will turn ON the Leds when the switch is pressed.

Note that the switches must be mechanical switches that short the connections. Rubber membrane switches do not have a low resistance when they are pressed.

Control7 switches02

Switch Test program

Now you can see the advantage of the Flowchart symbol table because you can refer to the components as PUSH 1 and PUSH2.

The IF icon on the flowchart tool bar is divided into digital comparsion and variables. You can see this with the small pop up that comes when you move the mouse over the icons.

If statements

Switch Test flowchart

Enter the flowchart symbols and connect as in the adjoining figure.

The PUSH 1 = 1 symbol turns on Light1 and turns OFF Light 2.

The PUSH2 = 1 symbol does the reverse.

Note that both lights are OFF when PUSH1 and PUSH 2 are OFF.

Note that PUSH1 AND PUSH2 conditions are not covered with this flowchart.

Simulate the operation as you press the two buttons corresponding to PUSH1 and PUSH2.

Program 3 reading switches

Program 2 basic file

Switch Test BASIC code

The above image shows the resultant code from your flowchart. You can identify the steps from the The PUSH 1 = 1 symbol turns on Light1 and turns OFF Light 2.T.

Download to your system and connect switches to SWITCH1 and SWITCH2 on the Control 7 board.

You should see LIGHTS1 and LIGHT2 come on when the switches are pressed.

Switch image on control 7 board

Switch Test discussion

If you look closely at the flowchart and the resultant code you can see a problem caused if BOTH SWITCH1 and SWITCH2 are pressed.

There is no path or direction for this particular event. In fact, if SWITCH1 is pressed, the program always loops to the first option and never gets down to checking on SWITCH2.

You can have a try with the flow chart and fix up the problem by having a special event linked to both SWITCH1 AND SWITCH2 being pressed.

This is the AND option that can be easily placed into your TEXT based BASIC program.

The line is

if PUSH1 = 1 AND PUSH2 = 1 Then BothOn.

You have to add another subroutine called BothOn that has both lights in he ON state.

.

swtches both ON
[Home] [About] [News] [Events] [Products] [CAD] [CAM] [Control] [Mechatronics] [Science] [Materials] [Support] [Map] [Contact]

PICMicro & Microchip logo are registered trademarks of Microchip Technology Inc. AZ. Atmel AVR & Atmel logo are registered trademarks of Atmel Corporation. CA. Philips Logo is a registered trademark of Philips Semiconductor Inc & Philips SA, Netherlands. Picaxe is a registered Trade mark of Microchip. Intellecta is a registered trademark of Intellecta Technologies. All other logos and trademarks are the property of their respective owners.  Revision Date June2006

© 1997- 2006 Intellecta Technologies - All rights reserved - email: supportatintellectadotnet