Final: Final Testing

On Tuesday, April 10th we did the final testing of the final project solutions with the young children from the Eliot Pearson School.

Robotics Students: please provide some documentation of your final testing and solution below.  This does NOT have to be extensive.  Please include the following:

  • Name of your project (and add your teammates as authors of the post)
  • Brief (couple sentence) description of your technical solution
  • Pictures (and if you have a video clip of it "in action" then great) of what you developed
  • Your code
  • And a description of how the testing went, both from a technical point of view and from a project-level point of view.


Final Testing

You Got the Feels?! Final Testing

Technical solution description

Our technical solution entails using LEGO color sensors to read the colored emotion cards, sending the information to the Raspberry Pi to calculate the score for each player, and moving the servo motor according to the scores. Various construction materials, including MyRio kit and acrylic board, were used to construct the rails on which the car runs, box in which all rails are enclosed, and the LED lights that indicate the submission of the answers.

Pictures:

Image

Left: Finalized Product

Top-right: Cars on the rails

Bottom-right: Color sensor station

Product in action (Slides 10 & 12)

Code

Final Testing Results Summary

Technical: Each sensors worked well to read the card in each round. Unlike the initial testing, we had no internet connectivity issue nor hardware issue. Improvement points that we notices were those of user interface and the rail distance. For user interface, we should be able to operate the monitor from the microprocessor (Rasp Pi) instead of plugging in separately into the laptop. Furthermore, the game can all be automated if on/off switch is attached onto the game board.For the rail distance, longer rail will help to show the difference in the distance that each score exhibits in more obvious way.

Curriculum: During our final testing session, we tested the prototype with two groups, each comprised of three Kindergartners. We implemented several changes that were effective with both groups: redesign of emotion cards so that children can better associate emotions with colors, more concise orientation to the emotion cards before playing the game, and better spatial orientation so that all children have visual access to the game and the display monitor. With both groups, we were able to engage in rich discussions with children about their differing answers. During the second game, however, one child became frustrated that he wasn't "winning" the game, which required us to explain the emotion cards more clearly and help him understand that even though he wasn't in the lead, he was still answering correctly.

Apr 24 2018 Read →

Slice It:

Description:

Our final testing for Slice It! took place last week to great success. After receiving feedback from our prototype stage, we aimed at implementing a new design and new features into our toy. For the final product, we managed to create a box that would image process the pieces placed on the game pad and then check to see if it correct. The focus of our product was to create a game that would help enrich the learning experience of elementary school kids in learning and experiencing fractions.

The actual game is a direct program python scrip on the raspberry pi that an individual would need to run. Inside the hardware is the rasperry pi which is connected to the camera. The camera lies below the game pad and allows it to take a picture when commanded to do so. We also have a button actuation for the camera to snap a photo when the user is ready to place answer from the game pad.

Image Image Image Image Image

Code for Level II:

from SimpleCV import *
from time import sleep
import os
from random import shuffle
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(15,GPIO.OUT)
GPIO.output(15,0) center = [385,325] mainScreen = Image("Title Screen.jpg")
mainScreen.show() try: while not GPIO.input(11): sleep(0.01)
except KeyboardInterrupt: GPIO.cleanup() sleep(2)
piCam = Camera()
disp = Display((640,480))
fracFiles = [os.path.abspath('JPGS/' + x) for x in os.listdir('JPGS')]
fracFiles.sort()
fracVals = [0.5, 0.33, 0.25, 0.125] fracIndex = range(0,len(fracVals))
shuffle(fracIndex) for i in fracIndex: fraction = Image(fracFiles[i]) fraction = fraction.scale(1.2) fraction.show() try: while not GPIO.input(11): sleep(0.01) except KeyboardInterrupt: GPIO.cleanup() fracPic = piCam.getImage() cropPic = fracPic.crop(385,325,400,400,centered=True) blobs = cropPic.findBlobs() blobs.draw(width=-1,color=Color.RED) area = blobs.area() maxArea = max(area) print(maxArea) totalArea = 139000 areaCovered =1-(maxArea/totalArea) print(areaCovered) takeClosest = lambda num, collection:min(collection,key=lambda x:abs(x-num)) estVal = takeClosest(areaCovered,fracVals) print(estVal) if estVal == fracVals[i]: print("Congrats!") else: print("Sorry!") 

Code for Level II:

from SimpleCV import *
from time import sleep
import os
from random import shuffle
import RPi.GPIO as GPIO GPIO.setmode(GPIO.BOARD)
GPIO.setup(11,GPIO.IN,pull_up_down=GPIO.PUD_DOWN)
center = [385,325] mainScreen = Image("Title Screen.jpg")
mainScreen.show()
sleep(5)
piCam = Camera()
disp = Display((640,480))
fracFiles = [os.path.abspath('Mode2/' + x) for x in os.listdir('Mode2')]
fracFiles.sort()
fracVals = [0.5, 0.33, 0.25, 0.125, 0.66, 0.25, 0.75, 0.5] fracIndex = range(0,len(fracVals))
shuffle(fracIndex) for i in fracIndex: fraction = Image(fracFiles[i]) fraction = fraction.scale(0.5) fraction.show() try: while not GPIO.input(11): sleep(0.01) except KeyboardInterrupt: GPIO.cleanup() fracPic = piCam.getImage().binarize() cropPic = fracPic.crop(385,325,400,400,centered=True) blobs = cropPic.findBlobs() blobs.draw(width=-1,color=Color.RED) area = blobs.area() maxArea = max(area) print(maxArea) totalArea = 139000 areaCovered =1-(maxArea/totalArea) print(areaCovered) takeClosest = lambda num, collection:min(collection,key=lambda x:abs(x-num)) estVal = takeClosest(areaCovered,fracVals) print(estVal) if estVal == fracVals[i]: print("Cool!") else: print("Sorry") 

Apr 18 2018 Read →

MagLev Train

Technical Solution

A “monorail” design of a train track, with a level train that travels over the top. Weights on the bottom keep the train level, while magnets on the bottom of the train and on the top of the track repel each other and cause the train to float. The spacing on the train was made more sturdy, and adjusted to reduce the friction between the train and the track. A separate robot travels alongside the track and causes the train to move, with an attached throttle that allows students to control speed and direction of the car and train. The car uses stronger magnets that better propel the train along the track, and making overall movement of the train smoother.

Pictures

Image Image

Code

Image

Testing

Testing went fantastically. Technically, we fixed all of the pressing issues from the first testing. There was much less friction between the train and the track, and control of the car allowed better interaction between the students and the train. We could tell that the better design of the train allowed students to have more fun.

From a developmental domain perspective, students were able to go from not really understanding how magnets worked, to being able to describe the operation of a MagLev train without any real prompting from us. This product has proven to be an effective aide in teaching magnetic forces to 1st - 2nd grade students.

Apr 17 2018 Read →

EMat

Robert Hrabchak, Riley Kolus, Meha Elhence, Hyejin Im, Kyle Paul

The Emat team sought to teach emotional literacy to 5-7 year old students. The robot Quinn acted as our character with dynamic emotional expression, moving around a color wheel as its emotions changed along with the children's emotions. At the end of the dialogue, the students could see a physical representation of how Quinn's emotions changed over time.

Our technical solution for having Quinn react to different prompts was to create a wirelessly controlled mobile robot platform. We used an Arduino Uno with a motor shield and two motors to drive Quinn around the board. We then added an XBee module to allow for wireless inputs to tell the robot when and where to move to. The Arduino recieved the serial inputs, and used two sensors to drive to the correct location on the board. A line sensor was mounted on the bottom, near the board, so that the robot would drive continuously along a ring around the board. A separate color sensor was mounted above the board, so that the robot knew to stop when it was located above the correct color.

Some of the challenges associated with this technique were due to the specific sensors used. The ir line sensors needed to be located in a very particular range of 2-5mm from the board. The color sensor was not particularly sensitive or repeatable, so it needed to be carefully calibrated each time the Arduino was turned on. The board that we printed had ten differently colored regions, and an outer and inner ring. The color sensor needed to be accurate enough to distinguish between the ten zones, and the ir line following sensor was given the capability to drive between the outer and inner circles when prompted.

Image Image Image

The final testing showed that the robot worked and the kids were entertained by the game. More importantly, the users demonstrated a better understanding of the emotional spectrum after identifying which of the robots faces related with which emotions.

Arduino Code: https://drive.google.com/open?id=1IiKbA8cXmUUeb17MLAmEIaJfgI7gPiuG

Apr 17 2018 Read →

SimQuake Final Testing

By: Andrew Sack, Annalisa DeBari, James Liao, Sahana Karthik

Description:

Our product is a small table-like structure with a platform that is able to move back and forth with different speeds. The purpose of this device is to simulate an earthquake, so the students can test the stability of their structures, which are built using spaghetti and marshmallows.

Our device is consists of an acrylic base, on which there are two rectangular wooden blocks mounted rigidly by hot glue, providing support for a gear and a rack. Only a part of the gear has teeth, and the rack is oval-shaped with teeth along the inner circumference. Using this mechanism, the rotational motion from the gear can be translated into linear motion by the rack. Powered by Lego EV3 motors, the rotating gear can move the rack back and forth, which in turn moves the platform back and forth.

Both the gear, rack, and platform were made using the laser cutter. The motors are mounted rigidly underneath the platform within a 3D-printed base, which is tightly hot glued to the base. The platform is mounted on top of the oval rack, so it moves along with the rack.

Testing:

Technical POV:

The shake table worked very well on testing day. Students were able to press the button and shake their structures. The speed was an input variable in the code so it was easy for Andrew to change the speed to challenge the kindergarten students' structures if it was able to stand for a while when the table was shaking. Occasionally the gear and rack mechanism got stuck but it was easily reset within seconds. The wooden material on the central gear was a good choice since the acrylic gears' teeth kept breaking prior to testing day.

Project Level:

The flow of the whole setup improved greatly the second time as the team had a better strategy of managing the students. The clear table top on the device was a nice feature so the students could see the gear and rack mechanism. The students enjoyed creating and testing their structures on the shake table, and were motivated to go back and improve their design. After testing for a bit, the students learned about the engineering process and how engineered devices require many cycles of testing. The group assessed the students’ understanding of the engineering design process via some questions about engineered products. Overall, the product reliability improved and the students enjoyed using it.

Video:

Code

Apr 16 2018 Read →

Spaco's Quest

Spaco's quest consisted of a maze game board, an EV3 two-motor robot (Spaco) and a raspberry pi four-button controller. To navigate the game board, kids used the controller to enter in a directional sequence for the EV3 robot to follow.

Final Testing:
The kids were able to play the game for the full testing period with little technical issue interruptions. However, there were some technical aspects of the project that could have been better. During testing, the EV3 to raspberry pi communication was no longer working smoothly. As soon as the issue was recognized, we used our plan b code that used a text file to give Spaco directions. We transitioned to using the other code very quickly so that the game was uninterrupted. Also, we had minor issues with Spaco occasionally straying an inch off of his assigned path.

The project was also a successful educational tool. Most of the kids were able to direct Spaco more quickly and correctly the more they played. This indicates great improvement in their directional and spacial skills.

RPi Controller:

Spaco makes use of a controller using the GoPiGo with four touch sensors connected using the GPIO pins. We also laser-cut a box to cover the wiring and buttons for the controller and labeled each for the specific motions of our robot.

Image Image

Our Code:

Our code sets up a loop that stores the sequence of motions of Spaco into an array after each button touch, running endlessly until the Go button is pressed and Spaco carries out the actions stored into the array "turns." Each button on our controller is linked to a function that has Spaco complete some action, either a right turn, and left turn, or move forward one square on or maze board. The Go button exists only to break the sequence storing loop. For each function , there are two iterations, the original that makes use of the Gyro sensor and allows for more precise movements, and the altered code, which was changed to a time dependent structure to counter the problems with inaccurate gyro sensor value communication due to the latency between the Rpi and the EV3 Brick.

Image Image Image Image Image

Apr 15 2018 Read →

BRYAN (Moral Development)

Building Respectful Young Achievers Now

Our technical solution to a robotic toy for moral development is BRYAN.  BRYAN is a robot that is powered by 3 keys.  The ideal usage of BRYAN is by a group of 3 children who each received 3 colored keys, which leaves 9 keys total in the game.  Theoretically, in individual can power the car themselves, inserting 3 keys of the same color.  This combination results in BRYAN moving slowly and only for about a foot.  Using 2 of one color and 1 of another allows BRYAN to move further than the previously mentioned combination, but BRYAN still does not complete the course.  BRYAN will only cross the finish line when maximum teamwork is used, meaning each player contributes 1 key to the car.

In more technical terms, the code reads the color of the keys used through LEGO color sensors.  Then, the number values are sorted to determine how many of each color key was used.  Finally, based on the how many of each color was used, the code sends power to the motor to make BRYAN move predetermined distances as discussed above.

Image Image Image

Code:

!/usr/bin/python3

ev3 = Device("this")

def manageRange(n):

return max(min(n,1050),-1050)

def main():

2 = Blue3 = Green5 = Red

sensor_1 = None

sensor_2 = None

sensor_3 = None

sensor_4 = None

occurrence_array = []

one_array = [1, 1, 2]

two_array = [0, 2, 2]

three_array = [0, 1, 3]

four_array = [0, 0, 4]

sensor_array = [0, 0, 0, 0]

motorB = ev3.LargeMotor('outD')

motorC = ev3.LargeMotor('outC')

read each sensor and store in first array

sensor_1 = ev3.ColorSensor('in1').color

print(sensor_1)

sensor_array[0] = sensor_1

sensor_2 = ev3.ColorSensor('in2').color

print(sensor_2)

sensor_array[1] = sensor_2

sensor_3 = ev3.ColorSensor('in3').color

print(sensor_3)

sensor_array[2] = sensor_3

sensor_4 = ev3.ColorSensor('in4').color

print(sensor_4)

sensor_array[3] = sensor_4

print(sensor_array)

occurrence_array.append(sensor_array.count(5))

occurrence_array.append(sensor_array.count(3))

occurrence_array.append(sensor_array.count(2))

print(occurrence_array)

occurrence_array.sort()

print(occurrence_array)

if occurrence_array == one_array:

motorB.run_forever(speed_sp = 500,stop_action="brake")

motorC.run_forever(speed_sp = 500,stop_action="brake")

sleep(3)

if occurrence_array == two_array:

motorB.run_forever(speed_sp = 400,stop_action="brake")

motorC.run_forever(speed_sp = 400,stop_action="brake")

sleep (2)

elif occurrence_array == three_array:

motorB.run_forever(speed_sp = 300,stop_action="brake")

motorC.run_forever(speed_sp = 300,stop_action="brake")

sleep(2)

elif occurrence_array == four_array:

motorB.run_forever(speed_sp = 200,stop_action="brake")

motorC.run_forever(speed_sp = 200,stop_action="brake")

sleep(1)

if name == 'main':

main()

Conclusions:

From a technical standpoint, BRYAN functioned very well.  The sensors functioned better with the keys, which we updated from the fuel discs.  We utilized a racecourse made of paper in this iteration, which allowed the technical team to make more precise distances and the children to compare their results of each trial more efficiently.

Overall, BRYAN was a very successful robotic toy to aid in the moral development domain.  He generated many smiles and at the end of using him, children were encouraged to work together.  In the scope of this class, BRYAN was victorious in achieving its goals and we believe could be taken a larger scale if desired.

Apr 11 2018 Read →

SEAQUENCE

Final Technological Solution:

Due to confusion from the children during our prototype testing with differentiating responses from sequences and success from failure, we decided to change our feedback mechanisms. This meant making a clearer differentiation between stimuli for the showing of sequences and the feedback for responses as well as adding standard messages to indicate success and failure. To make this as clear as possible, our final project technological solution combines robotics with pseudo-robotics. Specifically, the built-in-map, sounds, showing of sequences, and success-failure feedback were all faux-robotic (a PowerPoint presentation and keyboard sounds over a Bluetooth speaker) operated by one of our team members during testing.

Hardware wise, our project has three separate colored stations, or EV3 bricks. Each station has a button and a flag of the proper color fixed to the motor. Each station is capable of rotating the flag to indicate that the button has been press by the children and sending information wirelessly. These four stations are all in turn controlled by a Raspberry Pi that acts as the “Simon”. This central computer runs the code that receives information from the four stations to piece together a collective response. Then, it analyzes the response to determine success or failure, which it then indicates on the green and red LEDs attached. Additionally, the Pi has a pushbutton attached that acts primarily as a kill-switch to start a level over.

Software wise, the code is parceled into four files, one for each level, run by the Raspberry Pi. For each file, the Pi first initializes all variables and devices for the game before defining two sub-functions. The first is for recording responses when only one color input is expected. The second is a function for recording two colors at once when the game requires the children to press two buttons simultaneously. Both functions respond by raising and then lowering the appropriate flag. After initializing all devices and functions, the code awaits the kill-switch before continuing. From there, each level, with the exception of the first, is essentially the same.

For the first level, the following loop contains an if statement waiting for the kill-switch to be pressed. This would end the level. Otherwise, the code runs the receive functions. This level is used strictly to get the children comfortable using the buttons and interacting with the robot. It can be concluded at any point.

The remaining levels contain a more complicated structure of embedded loops. The highest level loop iterates over the ten sequences that make up each level. Within this, there is a small section of code that instructs both LEDs to blink a number of times equal to the sequence number. This is show the operator how far the code has progressed in case the print command stops working. Within each iteration of the sequence loops, an embedded while loop then contains the rest of the logic. First, the code utilizes three if statements that determine whether the response is correct or incorrect. When a correct solution triggers the first if statement, the loop will be broken and the higher level loop will iterate to the next sequence. When an incorrect response of equal length to the solution is found or the kill switch is pressed triggering the second or third condition, respectively, the loop resets the response variable and begins again from scratch. If none of these criteria are met, the code continues waiting for sensory input using one, or both, of the subprograms defined above.

Testing:

Before the test, we ran all the levels and everything work pretty well. However, when it comes to the kids, the system went wrong. Reaction of the buttons became very slow and since the kids often blocked the motion of motors with their hands and bodies, motors often couldn't get back to the initial position. We tried to ran the program again, reboot the IDE, but all didn't help a lot. At last, we restarted all of the LEGO kits. It took a while and our teammates tried to play other games with the kids. After the restart, everything went much better. One reason we thought that  might cause the problem was that since kids often pressed each button for many times before the motor response, the program might stuck because it received to many commands in a short time. Also, it might be a network issue for the IP address of our LEGOs changed several times and this never happened before. We learned a lot from the testing, even though we made many updates after the first test, we are still not well-considered enough on the kids' perspective. Besides, we should have a back up plan so that when something goes wrong, we could also let the kids to try some parts of our games.

Pictures:

Image Image

Code:

(there's a lot but it's pretty repetitive)

Common for all levels:

import RPi.GPIO as GPIO def main(): # define hardware gpg = Device("this") killSwitch = gpg.init_button_sensor("AD2") Correct_LED = 17 GPIO.setmode(GPIO.BCM) GPIO.setup(Correct_LED,GPIO.OUT) GPIO.output(Correct_LED,GPIO.LOW) Wrong_LED = 27 GPIO.setmode(GPIO.BCM) GPIO.setup(Wrong_LED,GPIO.OUT) GPIO.output(Wrong_LED,GPIO.LOW) print('Pi Initiated') stationR = Device('172.16.216.92') motorR = stationR.LargeMotor('outA') buttonR = stationR.TouchSensor('in1') print('Red Initiated') stationY = Device('172.16.143.207') motorY = stationY.LargeMotor('outA') buttonY = stationY.TouchSensor('in1') print('Yellow Initiated') stationG = Device('130.64.142.80') motorG = stationG.LargeMotor('outB') buttonG = stationG.TouchSensor('in1') print('Green Initiated') tag = 0 # "receive" function # 1 = red # 2 = yellow # 3 = green def receive( response, i ): tag = 1 if buttonR.is_pressed == 1: motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.6) motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response.append(1) print(response) i=i+1 sleep(1) elif buttonY.is_pressed == 1: motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.6) motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response.append(2) print(response) i=i+1 sleep(1) elif buttonG.is_pressed == 1: motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.6) motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response.append(3) print(response) i=i+1 sleep(1) return # "receive2" function # 4 = red and yellow # 5 = red and green # 6 = yellow and green def receive2( response, i, tag ): if buttonR.is_pressed == 1 and buttonY.is_pressed == 1: motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.6) motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response.append(4) print(response) sleep(1) tag = 1 elif buttonR.is_pressed == 1 and buttonG.is_pressed == 1: motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.6) motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response.append(5) print(response) sleep(1) tag = 1 elif buttonY.is_pressed == 1 and buttonG.is_pressed == 1: motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.6) motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response.append(6) print(response) sleep(1) tag = 1 return # wait for go GPIO.output(Correct_LED,GPIO.HIGH) print('Waiting for go...') while True: if killSwitch.is_button_pressed(): GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.5) GPIO.output(Correct_LED,GPIO.LOW) GPIO.output(Wrong_LED,GPIO.LOW) break

Level 1:

 # Level 1 print('LEVEL 1') response = [] i = 0 while True: if killSwitch.is_button_pressed(): print('Kill switch') GPIO.output(Correct_LED,GPIO.HIGH) GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.5) GPIO.output(Correct_LED,GPIO.LOW) GPIO.output(Wrong_LED,GPIO.LOW) break else: receive2( response , i, tag ) if tag == 0: receive( response , i ) sleep(.2) tag = 0 print('LEVEL 1 DONE') if __name__ == '__main__': main()

Level 2:

 # LEVEL 2 print('LEVEL 2') j = 1 while j < 11: solutionA = [2] solutionB = [3] solutionC = [1] solutionD = [3] solutionE = [2] solutionF = [1] solutionG = [2] solutionH = [1] solutionI = [3] solutionJ = [2] i = 0 response=[] print(j) k = 0 sleep(.5) while k < j: GPIO.output(Correct_LED,GPIO.HIGH) GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.1) GPIO.output(Correct_LED,GPIO.LOW) GPIO.output(Wrong_LED,GPIO.LOW) sleep(.1) k = k + 1 while True: if (response==solutionA and j==1) or (response==solutionB and j==2) or (response==solutionC and j==3) or (response==solutionD and j==4) or (response==solutionE and j==5) or (response==solutionF and j==6) or (response==solutionG and j==7) or (response==solutionH and j==8) or (response==solutionI and j==9) or (response==solutionJ and j==10): #print(response) print('correct') GPIO.output(Correct_LED,GPIO.HIGH) sleep(.5) GPIO.output(Correct_LED,GPIO.LOW) j = j + 1 break elif len(response)==1: #print(response) print('wrong') GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.5) GPIO.output(Wrong_LED,GPIO.LOW) motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.5) motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response=[] elif killSwitch.is_button_pressed(): print('Kill switch') GPIO.output(Correct_LED,GPIO.HIGH) GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.5) GPIO.output(Correct_LED,GPIO.LOW) GPIO.output(Wrong_LED,GPIO.LOW) motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.5) motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response = [] else: receive( response , i ) print('LEVEL 2 DONE') if __name__ == '__main__': main()

Level 3:

 # LEVEL 3 print('LEVEL 3') j = 1 while j < 11: solutionA = [1,2,3] solutionB = [3,2,2] solutionC = [2,1,3] solutionD = [2,3,3] solutionE = [1,3,2] solutionF = [3,1,3] solutionG = [3,2,1] solutionH = [1,3,3] solutionI = [1,1,1] solutionJ = [2,3,2] i = 0 response=[] print(j) k = 0 sleep(.5) while k < j: GPIO.output(Correct_LED,GPIO.HIGH) GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.1) GPIO.output(Correct_LED,GPIO.LOW) GPIO.output(Wrong_LED,GPIO.LOW) sleep(.1) k = k + 1 while True: if (response==solutionA and j==1) or (response==solutionB and j==2) or (response==solutionC and j==3) or (response==solutionD and j==4) or (response==solutionE and j==5) or (response==solutionF and j==6) or (response==solutionG and j==7) or (response==solutionH and j==8) or (response==solutionI and j==9) or (response==solutionJ and j==10): #print(response) print('correct') GPIO.output(Correct_LED,GPIO.HIGH) sleep(.5) GPIO.output(Correct_LED,GPIO.LOW) j = j + 1 break elif len(response)==3: #print(response) print('wrong') GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.5) GPIO.output(Wrong_LED,GPIO.LOW) motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.5) motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response=[] elif killSwitch.is_button_pressed(): print('Kill switch') GPIO.output(Correct_LED,GPIO.HIGH) GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.5) GPIO.output(Correct_LED,GPIO.LOW) GPIO.output(Wrong_LED,GPIO.LOW) motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.5) motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response = [] else: receive( response , i ) print('LEVEL 3 DONE') if __name__ == '__main__': main()

Level 4:

 # LEVEL 4 print('LEVEL 4') j = 1 while j < 11: solutionA = [1,5] solutionB = [2,6] solutionC = [2,4] solutionD = [3,5] solutionE = [3,6] solutionF = [1,6,1] solutionG = [3,5,2] solutionH = [3,4,2] solutionI = [1,5,2,3] solutionJ = [2,6,3,1] i = 0 response=[] print(j) k = 0 sleep(.5) while k < j: GPIO.output(Correct_LED,GPIO.HIGH) GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.1) GPIO.output(Correct_LED,GPIO.LOW) GPIO.output(Wrong_LED,GPIO.LOW) sleep(.1) k = k + 1 while True: if (response==solutionA and j==1) or (response==solutionB and j==2) or (response==solutionC and j==3) or (response==solutionD and j==4) or (response==solutionE and j==5) or (response==solutionF and j==6) or (response==solutionG and j==7) or (response==solutionH and j==8) or (response==solutionI and j==9) or (response==solutionJ and j==10): #print(response) print('correct') GPIO.output(Correct_LED,GPIO.HIGH) sleep(.5) GPIO.output(Correct_LED,GPIO.LOW) j = j + 1 break elif (len(response)==2 and j<6) or (len(response)==3 and j<9) or len(response)==4: #print(response) print('wrong') GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.5) GPIO.output(Wrong_LED,GPIO.LOW) motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.5) motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response=[] elif killSwitch.is_button_pressed(): print('Kill switch') GPIO.output(Correct_LED,GPIO.HIGH) GPIO.output(Wrong_LED,GPIO.HIGH) sleep(.5) GPIO.output(Correct_LED,GPIO.LOW) GPIO.output(Wrong_LED,GPIO.LOW) motorG.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=-180, speed_sp=400, stop_action="hold") sleep(.5) motorG.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorY.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") motorR.run_to_rel_pos(position_sp=180, speed_sp=400, stop_action="hold") response = [] elif len(response)==1: receive2( response , i ) else: receive( response , i ) print('LEVEL 4 DONE') print('YAY WIN!') if __name__ == '__main__': main()

Apr 10 2018 Read →