Tag Archives: Pi

Using a capacitative touch sensor with the Raspberry Pi or the Arduino

A capacitative touch sensor is simply a sensor that detects touch. Well, not actually touch. It somehow detects you and generates a response which the Pi can use anyway you want like a switch.

I’ve recently got a bunch of these.

proximity_2013_06_15_IMG_1912

 

Designed by  Adafruit.  They cost about £5 – £6.  The one used in this project is the one on the right.

Wiring

I’ve found that it’s best to connect it up and add the power supply last. It’s incredibly sensitive.

We used Conductive Paint to paint a picture.

BAR-33_1000x500-720x415

A wire was connected to the picture. You can use conductive sheet or anything that conducts – even playdough can work.

Connect the wire to the input. On the opposite side, connect a wire to one of the Pi input pins (5,7,8, 10,19 ,21,22,23
24,26,) or one of the Arduino analog inputs.

Repeat for the other inputs. Connect the ground to the GROUND and the VCC to the Power. I’ve used 3.3 V.

To test, put your hand over the conductive device. You should see an LED come on on the device. Remove your hand and it goes out.

If you read the sensor value for the Pin, the default is 1 and if contact is made, the sensor reads 0.

Use this sensor value as you want in Scratch GPIO or Scratch for Arduino

Using the Raspberry Pi and Scratch to make LEDs light up

Simon Walters at Cymplecy has modified Scratch so it can be used to control the GPIO pins.

In this tutorial, I will show you how to control the LEDs through Scratch and the Pi.

Install Scratch GPIO

Follow the instructions at Cymplecy to install Scratch GPIO on your computer. Once installed, start it up and you’ll see it looks similar to Scratch.

Equipment

Breadboard

Resistors (typically about 50  ohm)

LEDS

Wires – female to male

Wiring

singleLEDforworkshop_bb

Note that the long leg on the LED is positive and needs to be on the side where the wire comes from the output pins.

The Pi has a number of GPIO pins for OUTPUTS. You can use 11,12,13,15,16 or 18. The odd numbers are on the left and the evens are on the right.

The code

Scratch has a BROADCAST function. You can create a BROADCAST message for the pins.

BROADCAST PIN11HIGH

or BROADCAST PIN11ON

So when you connect a function such as

WHEN SPACE BAR PRESSED, BROADCAST PIN11HIGH

piswitch

The LED will light up. If it does not work, check your wiring. If you connect the wire from Pin11 to Pin1, this supplies 3.3V and the LED will light up.

To turn the LED off,

BROADCAST PIN11LOW

or BROADCAST PIN11OFF

You can also control Power by creating a VARIABLE

Create a VARIABLE called Power11.

You can then set the VARIABLE to a number between 0 and 100.

variablePi

You can connect multiple LEDs by using a common GROUND.

multipleLEDforworkshop_bb

Once you have control over the LEDs, you can link it to the Scratch program and make things happen.

Instead of LEDs, you can use simple buzzers as OUTPUTS. Don’t use motors as they need more power than the Pi can supply.

Video tutorial for the  Arduino

The Raspberry Pi

The Raspberry Pi and the Arduino

 

The Raspberry Pi is a small computer which is more powerful than it first appears. Pupils learn how to use Scratch on the Pi and then learn how to connect it to an Arduini board.

An Arduino board is a microcontroller with a number of inputs and outputs. Pupils use Scratch for Arduino to send a program to the microcontroller. The Arduino receives the inputs and responds as the pupil wants in the program.

ArduinoUno