Translates the true/false of the muscles to the movement that should take place

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 DigitalOut gpo(D0);
00004 DigitalOut led(LED_RED);
00005 
00006 //Constants
00007 int m = 100;
00008 
00009 // For making the system work in the end: 
00010 //      - Replace the input stated directly below
00011 //      - Replace the output given with the output needed
00012 
00013 // function determines which movement the system will make
00014 // It will check if the right and/or left muscle is contracted and then mention in which state the system is in    
00015 
00016 void check_state(&state_left, &state_right)
00017         //If the left mucle is contracted:
00018         if (state_left == true)
00019             {
00020                 //The right muscle is contracted as is the left muscle
00021                 if (state_right == true)
00022                     {
00023                         //Set value to keypress
00024                         string state = "keypress";
00025                     }
00026                 // The left mucle is contracted and the right is not
00027                 else 
00028                     {
00029                         // Set value to left
00030                         string state = "left";
00031                     }
00032             }
00033         //If the left muscle is not contracted
00034         else 
00035             {
00036                 // Right mucle is contracted and left is not
00037                 if (state_right == true)
00038                     {
00039                         //Set value to right
00040                         string state = "right";
00041                     }
00042                 //None of the muslces is contracted (rest)
00043                 else
00044                     {
00045                         // Set value to rest
00046                         string state = "rest";
00047                     }
00048             }
00049     }
00050 
00051 void check_state(&state) {
00052     if (state = state_old) {
00053         sequential = sequential + 1;
00054         if (sequential > m) {
00055             //move motor
00056             
00057             //Don't let sequential fully reset. This way the piano can be played faster. 
00058             sequential = sequential/2;
00059             }
00060         }
00061     else {
00062         sequential = 0;
00063         state_old = state;
00064         }
00065 
00066 int main()
00067 {
00068     check_state()
00069     check_change_state()
00070 }