Skip to content

Commit

Permalink
Merge pull request #206 from oss-slu/issue_199
Browse files Browse the repository at this point in the history
Touch Switch Documentation Issue #199
  • Loading branch information
ruthvikm authored Mar 21, 2024
2 parents 038e646 + 0b73782 commit 143469a
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.micronaut.http.annotation.Get;
import jakarta.inject.Named;

//tag::ex[]
@Controller("/touchSwitch")
public class TouchSwitchController {

Expand Down Expand Up @@ -37,4 +38,5 @@ public void enableTouchSwitch() {
public void disableTouchSwitch() {
touchSwitchHelper.removeEventListener();
}
}
}
//end::ex[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
:imagesdir: img/

ifndef::rootpath[]
:rootpath: ../../
endif::rootpath[]

ifdef::rootpath[]
:imagesdir: {rootpath}{imagesdir}
endif::rootpath[]

==== Touch Switch

[.text-right]
https://github.com/oss-slu/Pi4Micronaut/edit/develop/micronautpi4j-utils/src/docs/asciidoc/components/inputComponents/touchSwitch.adoc[Improve this doc]

===== Overview

This section provides details of a touch switch sensor implementation,
including its circuit diagram, required hardware components,
assembly instructions, and functionality.

===== Components

. Touch switch module
. LED light
. 1 x 220Ω resistor
. Breadboard
. Jumper wires
. Power source

===== Assembly Instructions

Connect the 3 pins on the touch switch to the breadboard as well as the LED and resistor
making sure the LED has power.

. Ground: connect the ground on the touch switch to the ground on the breadboard
. Power: Connect the VCC on the touch switch to the 3.3V on the breadboard
.. You will want to have a wire connecting 3.3V and ground to the bottom of the board
so that power can be supplied to the LED and touch switch as shown in the diagram below
. IO: Connect the IO on the touch switch to GPIO 17 on the breadboard which is the digital input
. Resistor: Place the resistor vertically so that it can connect the LED light to power
. Connect a wire from GPIO26 to the LED which is its digital output

===== Circuit Diagram

Model:

image:touchSwitchDiagram.png[]

Circuit Diagram:

image:touchSwitch.png[]

===== Functionality

Once the touch switch has been enabled, touching the sensor will turn the LED light on
and removing your finger from the sensor will turn the LED light off.

===== Testing the Circuit

To enable the touch switch:

[source, bash]
----
curl http://localhost:8080/touchSwitch/enable
----

To disable the touch switch:

[source, bash]
----
curl http://localhost:8080/touchSwitch/disable
----

===== Troubleshooting

- LED not lighting up once it has been enabled and is being touched:
Make sure that all the pins on the touch switch are in the right spot and that everything is receiving power.
Also make sure that everything is properly secured to the breadboard.
- Ensure a 220Ω resistor is being used

===== YAML Pin Order

The YAML configuration for the LED is as follows:

[source, yaml]
----
digital-output:
led2:
name: LED Output
address: 26
shutdown: HIGH
initial: HIGH
provider: pigpio-digital-output
----
So, the output of the LED is connected to GPIO 26.

The YAML configuration for the touch switch is as follows:

[source, yaml]
----
digital-input:
touch-switch-input:
name: Touch Switch Input
address: 17
pull: PULL_DOWN
debounce: 200000
provider: pigpio-digital-input
----
So, the input of the touch switch is connected to GPIO 17.

===== Constructor and Methods

To see the constructor and methods of our TouchSwitchHelper class see our javadoc link:https://oss-slu.github.io/Pi4Micronaut/javadoc/com/opensourcewithslu/inputdevices/TouchSwitchHelper.html[here]
for more details.

===== An Example Controller

====== This controller uses the touch switch to light up a LED light once touched

[source, java]
----
include::../../../../../../components/src/main/java/com/opensourcewithslu/components/controllers/TouchSwitchController.java[tag=ex]
----
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pi4micronaut-utils/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ include::components/inputComponents/photosensor.adoc[]

include::components/inputComponents/ultraSonicSensor.adoc[]

include::components/inputComponents/touchSwitch.adoc[]


include::components/outputComponents.adoc[]

Expand All @@ -76,5 +78,3 @@ include::components/outputComponents/led.adoc[]
include::components/outputComponents/rgbLed.adoc[]

include::components/outputComponents/lcd1602.adoc[]


0 comments on commit 143469a

Please sign in to comment.