Search found 126 matches

by OlivierLenoir
Mon Jul 04, 2022 4:29 am
Forum: General Discussion and Questions
Topic: random.sample or similar?
Replies: 6
Views: 2229

Re: random.sample or similar?

Code: Select all

print(f'{t} - {target}')
It's a String Formatting. it is equivalent to this:

Code: Select all

print('{t} - {target}'.format(t=t, target=target))
by OlivierLenoir
Sun Jul 03, 2022 6:33 am
Forum: General Discussion and Questions
Topic: random.sample or similar?
Replies: 6
Views: 2229

Re: random.sample or similar?

As you just want to pop a target once. You do this: from random import choice targets = ['Target1', 'Target2', 'Target3', 'Target4', 'Target5', 'Target6', 'Target7', 'Target8', 'Target9', 'Target10'] count_target = range(len(targets)) for t in count_target: target = choice(targets) targets.remove(ta...
by OlivierLenoir
Sun Jul 03, 2022 6:13 am
Forum: General Discussion and Questions
Topic: random.sample or similar?
Replies: 6
Views: 2229

Re: random.sample or similar?

You can use random.choice() . from random import choice targets = ['Target1', 'Target2', 'Target3', 'Target4'] for t in range(10): target = choice(targets) print(f'{t} - {target}') Output is: 0 - Target4 1 - Target1 2 - Target1 3 - Target3 4 - Target3 5 - Target4 6 - Target1 7 - Target4 8 - Target2 ...
by OlivierLenoir
Wed Jun 08, 2022 7:22 pm
Forum: Pyboard D-series
Topic: ble 2 sensors and 1 station?
Replies: 4
Views: 44711

Re: ble 2 sensors and 1 station?

Did you look for MQTT and MQTT Mosquito server?
MicroPython implement umqtt/simple and umqtt/robust.
Oups, I thought it was ESP32.
by OlivierLenoir
Wed Jun 08, 2022 5:04 am
Forum: General Discussion and Questions
Topic: Avatar picture size
Replies: 3
Views: 1054

Re: Avatar picture size

Nice to see you francis. :D
by OlivierLenoir
Mon Jun 06, 2022 7:23 pm
Forum: General Discussion and Questions
Topic: Avatar picture size
Replies: 3
Views: 1054

Re: Avatar picture size

I would recommend to use ImageMagick and it's convert command.

Code: Select all

convert <SquareInputImage.jpg> -thumbnail 90x90 -define jpeg:extend=8kb <SquareOutputImage90.jpg>
by OlivierLenoir
Wed Apr 27, 2022 4:00 pm
Forum: ESP32 boards
Topic: How to drive a stepper motor with S curve?
Replies: 2
Views: 1243

Re: How to drive a stepper motor with S curve?

You can read this topic.
Project is here.
by OlivierLenoir
Sun Apr 24, 2022 4:49 am
Forum: General Discussion and Questions
Topic: Chessboard robot
Replies: 10
Views: 4103

Re: Chessboard robot

I've code a Neural Network in MicroPython . This project has been used to categorized color by machine learning. But we can do more with this type of Neural Network . This article, AntBot , it's in french, but, they've implemented a two bit celestial compass . It maybe an inspiration for your project.
by OlivierLenoir
Sat Apr 23, 2022 7:28 am
Forum: General Discussion and Questions
Topic: Chessboard robot
Replies: 10
Views: 4103

Re: Chessboard robot

You can add a sensor to detect if you are on a black or white square.
by OlivierLenoir
Thu Mar 24, 2022 5:10 pm
Forum: ESP32 boards
Topic: Need a function that controls number of beeps
Replies: 3
Views: 1205

Re: Need a function that controls number of beeps

This code should work for you. from machine import Pin, PWM from utime import sleep_ms BUZ_PIN = const(16) def buzzer(n=3, freq=4000): buzzer = PWM(Pin(BUZ_PIN)) buzzer.freq(freq) for _ in range(n): buzzer.duty_u16(1<<15) sleep_ms(500) buzzer.duty_u16(0) sleep_ms(500) buzzer.deinit()