Here we find code to hack and learn the Arduino needed to understand codes in Arduino Z repository

Juan Keymer fa471354be Edited README 2 mesi fa
EasyDriver_SImplest.ino 6b281699d1 First commit 2 mesi fa
README.md fa471354be Edited README 2 mesi fa
push_button_pull_up.ino 6b281699d1 First commit 2 mesi fa
push_button_pull_up_with_Serial.ino 6b281699d1 First commit 2 mesi fa

README.md

Arduino Files for hacking HomeScope's Z axis

Here we can find files which contain modular elements of code needed to understand the Arduino Z code.

Push-down buttons

When the 2-state machine Arduino Z is on the listening state is waits for the user to communicate its wishes. The user does this by pressing a Push-down button.

For a user to "talk" to Arduino Z, we use push-down buttons. Two of them to move the microscope stage up and down. These buttons are pulled up so when they are not pressed they are in the HIGH state and when pressed they get grounded to the LOW state. To learn about pulling up (internally or externally) and why is needed for input you can read here:

https://roboticsbackend.com/arduino-input_pullup-pinmode/

Two codes are presemted here.

Here we supply the simplest possible pice of code that shows how to light up a LED by pressing a single button down button

push_button_pull_up.ino

Anoother file we list here adds a Serial Port interface to the code listed above. This allows us to transmit the state variable (buttonPin) to the host computer using the serial port.

push_button_pull_up_with_Serial.ino

EasyDriver control of a Stepper motor

When the 2-state machine Arduino Z is on the actuating state it goes ahead and "exacute" the wishes of the user. That is moves HomeScope's stage up and down by moving a Stepper motor.

Stepper motors move in discrete steps (200 steps correspond to 360 degrees rotation). To control the motor, Arduino Z talks to an EasyDriver motor controller board. To learn more about the EasyDriver go:

https://www.schmalzhaus.com/EasyDriver/index.html

The messages from Arduino to EasyDriver are transmited via 2 GPIOs. One GPIO is for setting direction (CW or CCW) and the other to perform a step foward in a direction. The EasyDriver, then control the motor phases to achieve the desired pattern of stteping.

The sample code here is the simplest possible. It makes the stepper motor ratate in a given direction forever. For more sofisticated code visit:

https://www.schmalzhaus.com/EasyDriver/Examples/EasyDriverExamples.html

Here we provide the simplest code possible:

EasyDriver_SImplest.ino README.md push_button_pull_up.ino push_button_pull_up_with_Serial.ino

You can play with this code, and now putting all togther, and adding a 2-state machine structure to the code, we can now understand the code files listed in the Arduino Z repository