Here's an example for how to use a paper circuit with the CPE -- you can use alligator clips to connect to the copper tape.
To make a better connection for the LED onto the paper circuit:
Use needle nose pliers to curl the LED leads.
Be sure you know which one is positive and which is negative!
Then, rest the LED on copper tape and use a small piece to "sandwich" the curled leads and make a decent connection.
Here's another example that shows how to connect two LEDs (in parallel).
You may need to play with the threshold value. If it's too low, then it will be very sensitive; sometimes just attaching an alligator clip will count as a "touch." In this case, use the Serial monitor to determine a better threshold value.
You may also find you need different thresholds depending on how the CPX is powered (via computer or USB battery).
Build a little component that "sandwiches" the velostat between two conductive layers of "bread."
Materials
1 small rectangle of velostat
The size is up to you -- the pictures in this tutorial use about 2" x 3"
In Fimbel, velostat is located in the Electronics Cabinet
A 10K resistor
In Fimbel, these are in the organizer above the soldering station. Look for the drawer that says 10k.
Copper tape
Paper/cardboard
Draw/cut out your sandwich "bread" layers using your velostat to guide the size. In the picture below, you'll see that the righthand side is set up to have 2 attachment areas, while the left side only has one.
Use copper tape to cover each "bread" layer/side.
The strips of copper tape should be complementary to each other to ensure that current can flow (through the velostat) from one side to the other.
Make sure that the copper tape from each layer of bread does not touch -- there must be velostat sandwiched between.
Use copper tape to attach the 10k resistor to one side. Use another piece of copper tape to attach the resistor.
Place the velostat between the two sides, and your velostat "sandwich" pressure sensor is complete!
Use 3 alligator clips to attach:
the resistor to a GND pin
the other strip of the same (ground) side to an analog pin
use A3 on the Circuit Playground to work with the sample code
the strip on the other side to a voltage 3.3V pin
The ~20mA current supplied by the control pins (A0, ...) on a CPX is not enough for a vibrating motor (the one below requires 90mA). Therefore, we use an n-channel MOSFET to supply current from the 3.3V pin directly (which can supply up to 300mA); the MOSFET is controlled by a pin to switch the current on/off.
MOSFET pins:
Gate -> CPX control pin (e.g., A0)
Drain -> one lead of motor
Source -> CPX 3.3V
Each MOSFET component may have different pin arrangements. This from the data sheet for the one linked above.
Gate (G) - controls the current flow between the Drain and Source terminals by varying the electric field created by the voltage applied to the Gate terminal.
Drain (D) - serves as the output terminal for the current flowing through the MOSFET to the load.
Source (S) - serves as the input terminal for the current flowing through the MOSFET from the source.
The pinout sequence is: G (Gate), D (Drain), S (Source).
1. Use copper tape to lay traces for the vibromotor. Make sure the connections are as tight as possible! Alligator clips can't reliably connect to the motor leads as they are very delicate!
2. Attach jumper wires or bend MOSFET pins for connections. If you use sockets, you really have to push them on to make the connection! If you bend, be sure that there are no unwanted connections!
3. Connect left/gate MOSFET pin to CPX A0.
4. Connect middle/drain MOSFET pin to copper tape for one lead of vibromotor.
5. Connect right/source MOSFET pin to CPX 3.3V.
6. Test with "blink" code for exter nal LED.
Micro Servo 9g SG90 (in Elegoo kits)
Attach your wires from the Servo to the CPE:
GND to GND (brown in the image)
Voltage to 3.3V or Vout (red in the image)
PWM control to A1 (orange in the image)
Double-check your connections and make sure no metal is touching other metal that you don't want!
The CPX can detect when an external switch is closed using an internal resistor. You can choose to use a "pull-up" or "pull-down" configuration. Here, we will use a pull-up.
Use this code, connecting one end of the switch to GND and the other to A0.
connecting the alligator clips closes the switch
(you can use any conductive materials!)