Switch

Intro :

When working with inputs and outputs you add to the areas requring debugging. One area can impact another.

In this example there the Functional Error exists in either the code or circuitry. The code successfully compiles and circuit connects but both result in an unexpected behaviour in the button/switch. Try decifer where the issue arises.

Select either the code or circuitry to resolve as you only need to identify the Functional Error in one of these areas to get the desired behaviour.

---------------------------------------------------------------------------->

Switching and LED on and off :

Pins

    Switch = D5
    LED = D13
---------------------------------------------------------------------------->

Feedback Shield :

If you have a feedback shield place it on top of your Arduino board and view what visual feedback you get when you make changes to your code.

Remember a digital signal is green if HIGH and red if LOW. This applies to both inputs and outputs.

Observe the relationship between the LED corresponding to pin D5 and the LED corresponding to pin D13

---------------------------------------------------------------------------->

Reflect :

Observe the output in the physical space. What is the physical LED doing in relation to the button press action?

When using the shield ...

    What colour is the corresponding LED for pin 13?
    How is the output LED behaving, is it changing colour when the button is pressed?
    Is the LED that corresponds to the button input changing colour?
    Do both shield LEDs behave in relation to each other?

In addition ...

    Is the button controlling the output LED?
    What may be missing in this Functional Error?
    How would you adapt the code to make the relationship between input to output correlate?
---------------------------------------------------------------------------->

Edit it :

Try edit the code or edit the circuit to turn the inactive/erratic switch into a controlled on/off behaviour. Consider what lines of code you may need to add to create the mechanical difference.

Copy the Function Error code below into your Arduino IDE and begin editing it. Once you think you have solved the Functional Error upload to your board to see the visual difference. Remember to check the board and port match your Arduino board and USB port in use.

---------------------------------------------------------------------------->
---------------------------------------------------------------------------->

J3n Sykes

GitHub | Back to examples