Week 8: Bicep function detector :)

Description

Create an unusual switch that doesn’t require the use of your hands. Use Arduino digital input and output for the interaction.

Process

Do your biceps work? Let’s find out! This is a switch that works using the mechanisms of your elbow. As you close your elbow the switch shows a green light, and when open it shows a red one.

So the programme requires basic coding. I use two LED lights, one red and one green, and wires to connect the flow of electricity. Using cardboard, I created two patches each to be applied on either sides of the inner side of the elbow, and put wires on each side, one going for the output (5V port)  and one for the input and taped it around my arm.

Then creating the following code where if and only if the electricity is flowing through the wire will the lights turn green, otherwise red indicating if the elbow is closed or open. Hence, showing if your biceps are working in your body or not!

CODE:

//declaring the constant variables
const int redPin = 8;
const int book = 6;
const int greenPin = 3;
bool currentState = false;
bool bookState = LOW;

void setup() {
  //determining the source function
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(book, INPUT);
}

void loop() {
    bookState = digitalRead(book); //reading the input of book switch
    //condition to change the lights 
    if (currentState != bookState ){
      digitalWrite(greenPin, HIGH); //green on, red off
      digitalWrite(redPin, LOW);
     } else {
      digitalWrite(greenPin, LOW);//green off red on 
      digitalWrite(redPin, HIGH);
    }
}

Leave a Reply