'My motor will not run with bluetooth on pico
I'm doing a project and I am using an HC-06, raspberry PICO, 28BYJ-48 Motor, and a ULN2003 Motor Driver. I coded the motor to turn and everything, and it all works perfectly. I debugged, and the Micropython interpreter shows no errors. I am using an app with it through my HC-06, and for some reason when everything is connected and my Bluetooth module shows as "Connected" on the app, it appears that the motor is not turning. Does anyone know what could be wrong? I am fairly new to Micropython. Here is my code:
from machine import Pin, Timer
from machine import UART
from utime import sleep
uart = UART(0, 9600)
number_of_steps = 1
max_steps = 10
pins = [
Pin(2, Pin.OUT),
Pin(3, Pin.OUT),
Pin(4, Pin.OUT),
Pin(5, Pin.OUT),
]
full_step_sequence = [
[1,0,0,0],
[0,1,0,0],
[0,0,1,0],
[0,0,0,1]
]
back_step_sequence = [
[0,0,0,1],
[0,0,1,0],
[0,1,0,0],
[1,0,0,0]
]
def rotate():
for step in full_step_sequence:
for i in range (len(pins)):
pins[i].value (step[i])
sleep(0.001)
def rotate_back():
for step in back_step_sequence:
for i in range (len(pins)):
pins[i].value (step[i])
sleep(0.001)
while True:
if uart.any():
data=uart.read()
data = str(data)
print(data)
if ('MUTE' in data):
rotate()
elif ('UNMUTE' in data):
rotate_back()
Solution 1:[1]
I have created a trigger via cloud function that listens on user creation and disables new users.
If you create a new user you need to enable the user in your firebase console.
Function code:
const onCreateHandler = (user: admin.auth.UserRecord, context: functions.EventContext) => {
if (!user.email) {
return null;
}
return admin.auth().updateUser(user.uid, {
disabled: true,
});
};
export const authUserCreatedTrigger = functions.region(functionsRegion).auth.user().onCreate(onCreateHandler);
With this method the user / hacker can't log in after registration.
You could also log the user creating in firestore and send yourself an notification (email) :)
You could also implement some custom access logic that is stored in firestore or custom user claims, which your frontend can use to decide what the user can or can not see.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
