From 121d9360f8d64adb085b089275ce461577dbba80 Mon Sep 17 00:00:00 2001 From: AdityaSingh17 Date: Sat, 26 Oct 2019 17:10:08 +0530 Subject: [PATCH 1/3] added program --- 07.LED_TOUCH_CONTROL/led_touch_control.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 07.LED_TOUCH_CONTROL/led_touch_control.py diff --git a/07.LED_TOUCH_CONTROL/led_touch_control.py b/07.LED_TOUCH_CONTROL/led_touch_control.py new file mode 100644 index 0000000..8802d63 --- /dev/null +++ b/07.LED_TOUCH_CONTROL/led_touch_control.py @@ -0,0 +1,18 @@ +import machine +from machine import TouchPad,Pin + +red = machine.Pin(15, machine.Pin.OUT) +blue = machine.Pin(4, machine.Pin.OUT) +green = machine.Pin(2, machine.Pin.OUT) + +on_pad = TouchPad(Pin(14)) +off_pad = TouchPad(Pin(12)) + +while True: + x = on_pad.read() + y = off_pad.read() + if (x<100): + green.on() + if (y<100): + green.off() + From fdf8f6686713c17833c5c21e451b408dc7d5a1f2 Mon Sep 17 00:00:00 2001 From: AdityaSingh17 Date: Sat, 26 Oct 2019 17:11:51 +0530 Subject: [PATCH 2/3] added readme --- 07.LED_TOUCH_CONTROL/readme.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 07.LED_TOUCH_CONTROL/readme.md diff --git a/07.LED_TOUCH_CONTROL/readme.md b/07.LED_TOUCH_CONTROL/readme.md new file mode 100644 index 0000000..896d93d --- /dev/null +++ b/07.LED_TOUCH_CONTROL/readme.md @@ -0,0 +1,12 @@ +# 04_ACCESS_POINT +To run the program use the following ampy command + +## MAC OS +```bash + ampy --port /dev/tty.SLAB_USBtoUART run led_touch_control.py +``` + +## Linux +```bash + ampy --port /dev/ttyUSB0 run led_touch_control.py +``` From 776a35a3e99d905caf4f46073c13a921576fee6f Mon Sep 17 00:00:00 2001 From: AdityaSingh17 Date: Sun, 27 Oct 2019 13:28:50 +0530 Subject: [PATCH 3/3] Added program for Touch control LED (ESP32) --- 07.LED_TOUCH_CONTROL/led_touch_control.py | 19 +++++++++++-------- 07.LED_TOUCH_CONTROL/readme.md | 5 ++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/07.LED_TOUCH_CONTROL/led_touch_control.py b/07.LED_TOUCH_CONTROL/led_touch_control.py index 8802d63..1b5f80b 100644 --- a/07.LED_TOUCH_CONTROL/led_touch_control.py +++ b/07.LED_TOUCH_CONTROL/led_touch_control.py @@ -1,18 +1,21 @@ +# Code to control LED by capacitive touch on the ESP32 board. + import machine from machine import TouchPad,Pin -red = machine.Pin(15, machine.Pin.OUT) +# The 4 pin LED pins are connected to GPIO pins numbered 15,4 and 2 in the following way: +red = machine.Pin(15, machine.Pin.OUT) blue = machine.Pin(4, machine.Pin.OUT) green = machine.Pin(2, machine.Pin.OUT) -on_pad = TouchPad(Pin(14)) -off_pad = TouchPad(Pin(12)) +on_pad = TouchPad(Pin(14)) # This will signal the touch for turning the LED on. +off_pad = TouchPad(Pin(12)) # This will signal the touch for turning the LED off. while True: - x = on_pad.read() + x = on_pad.read() # Read the sensor values and wait for a touch. y = off_pad.read() - if (x<100): - green.on() - if (y<100): - green.off() + if (x<100): # When the ON sensor is touched, turn on the LED. + green.on() # We are using the Green colored LED as an example, any of the LED colors may be used. + if (y<100): # When the OFF sensor is touched, turn off the LED. + green.off() diff --git a/07.LED_TOUCH_CONTROL/readme.md b/07.LED_TOUCH_CONTROL/readme.md index 896d93d..f1d77e7 100644 --- a/07.LED_TOUCH_CONTROL/readme.md +++ b/07.LED_TOUCH_CONTROL/readme.md @@ -1,4 +1,7 @@ -# 04_ACCESS_POINT +# 07.ACCESS_POINT +## NOTE: +This program will run only on the *ESP32* board, as it is using the capacitive touch functionality. + To run the program use the following ampy command ## MAC OS