07 March 2025

Scaffolding: Progress Review Team 9

 For the game Dr. Mario (NES) this controller mimics a pharmacy pill counting station. The spatula will move the pill left and right with a toggle switch. The pill dial will rotate the pill clockwise and counter-clockwise. Lastly, the pill bottle and cap use a light sensor inside the bottle to detect if you have closed the bottle, almost closed it, or have not closed it to hard drop or soft drop the pill. This is spring loaded so it resets back to not dropping the pill as well as for convenience of use. This controller provides the pharmaceutical experience as well as all the controls needed to play the game intuitively.


[include libraries]

[Initialize pins]

Joystick_x_pin = A1;

light_sensor_pin = A2;

Dial_pin = A3;

 

Joystick_threshhold_left = 300 #adjustable

Joystick_threshhold_right = 700 #adjustable

 

rotation_threshhold = 90 #adjustable

Previous_dial_value = 0 #initial value 

 

[Variables]

ReadA1 = spatula;

ReadA2 = bottle;

ReadA3 = pill;

 

Void Setup()

pinMode(dial_pin, Input);

pinMode(joystick_x_pin,Input);
pinMode (light_sensor_pin, Input);

 

Void moveObject(string direction)

if (direction == “left”)

                serial.println(“The pill moved left”)

Else if (direction == “right”)

                serial.println(“ the pill moved to the right”)

 

void rotateObject

                If (direction == “Clockwise”)

Press and Release X
                Serial.println(“Clockwise”)

                If (direction == “CounterClockwise”)

Press and Release Z
                Serial.println(“CounterClockwise”)

                Else (direction == “noTurn”)

Release X and Z           

 

Void Loop()

If Light_value == LOW{

Press and hold down Key

Else if Light_value == MID{

Tap Down Key

Else if Light_value == HIGH{

Release Down Key

 

If (joystick_x_value < joystick_threshhold_left) {
                moveObject(“left”) ;

Else if (joystick_x_value > joystick_threshhold_right) {

                moveObject(“right”)

Else (joystick_x_value > joystick_threshhold_500) {

                moveObject(“no move”)

 

Global previous_dial_value
If (dial_value >= previous_dial_value + rotation_threshhold) { 

                rotateObject(“clockwise”)
                Set Previous_dial_value = dial_value

Else if (dial_value <= previous_dial_value - rotation_threshhold) {

                rotateObject(“counterClockwise”)

                Set Previous_dial_value = dial_value

Else{

                rotateObject(“noTurn”)

                Set Previous_dial_value = dial_value

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.