update(General)
This commit is contained in:
parent
44cc65add0
commit
441352559a
|
|
@ -0,0 +1 @@
|
||||||
|
**/.nvim/
|
||||||
|
|
@ -0,0 +1,6 @@
|
||||||
|
# Arduino
|
||||||
|
|
||||||
|
`arduino`
|
||||||
|
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Object
|
||||||
|
|
||||||
|
|
||||||
|
## led
|
||||||
|
|
@ -15,37 +15,3 @@ cd thonny-4.1.7
|
||||||
```
|
```
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Code
|
|
||||||
|
|
||||||
### (HIGH) status
|
|
||||||
led.value(1)
|
|
||||||
led.on()
|
|
||||||
|
|
||||||
### (LOW) status
|
|
||||||
|
|
||||||
led.value(0)
|
|
||||||
led.off()
|
|
||||||
|
|
||||||
|
|
||||||
### Pin
|
|
||||||
led_placa = Pin(2, Pin.OUT, value=1)
|
|
||||||
|
|
||||||
### Button
|
|
||||||
boton_up = Pin(4, Pin.IN, Pin.PULL_DOWN)
|
|
||||||
|
|
||||||
|
|
||||||
## Mod
|
|
||||||
|
|
||||||
### Time
|
|
||||||
|
|
||||||
import utime
|
|
||||||
|
|
||||||
utime.sleep(<segundos>)
|
|
||||||
|
|
||||||
utime.sleep_ms(<milisegundos>)
|
|
||||||
|
|
||||||
utime.sleep_us(<microsegundos>)
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
|
|
||||||
from machine import Pin
|
from machine import Pin
|
||||||
import utime
|
import utime
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class taller2:
|
class taller2:
|
||||||
# display_common_cathode
|
# display_common_cathode
|
||||||
catodos = (
|
catodos = (
|
||||||
|
|
@ -85,7 +81,7 @@ def main():
|
||||||
|
|
||||||
for key, value in secmentos.items():
|
for key, value in secmentos.items():
|
||||||
value.on()
|
value.on()
|
||||||
utime.sleep_ms(160)
|
utime.sleep_ms(500)
|
||||||
value.off()
|
value.off()
|
||||||
|
|
||||||
program = taller2()
|
program = taller2()
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,106 @@
|
||||||
|
from machine import Pin
|
||||||
|
import utime
|
||||||
|
|
||||||
|
|
||||||
|
class taller3:
|
||||||
|
pin_board = Pin(2, Pin.OUT, value = 0)
|
||||||
|
pin_yellow = Pin(25, Pin.OUT, value = 0)
|
||||||
|
pin_white = Pin(26, Pin.OUT, value = 0)
|
||||||
|
pin_green = Pin(27, Pin.OUT, value = 0)
|
||||||
|
|
||||||
|
# Pin input
|
||||||
|
# 34
|
||||||
|
button_1 = Pin(32, Pin.IN, Pin.PULL_UP)
|
||||||
|
button_2 = Pin(35, Pin.IN, Pin.PULL_UP)
|
||||||
|
button_3 = Pin(34, Pin.IN, Pin.PULL_UP)
|
||||||
|
|
||||||
|
In1 = Pin(5, Pin.OUT, value = 0)
|
||||||
|
In2 = Pin(18, Pin.OUT, value = 0)
|
||||||
|
In3 = Pin(19, Pin.OUT, value = 0)
|
||||||
|
In4 = Pin(21, Pin.OUT, value = 0)
|
||||||
|
|
||||||
|
motor_pin = {In1, In2, In3, In4}
|
||||||
|
|
||||||
|
s1 = Stepper.create(In1, In2, In3, In4)
|
||||||
|
s1.step(1018, -1)
|
||||||
|
|
||||||
|
paso_1 = (
|
||||||
|
int('1000', 2),
|
||||||
|
int('0100', 2),
|
||||||
|
int('0010', 2),
|
||||||
|
int('0001', 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
paso_2 = (
|
||||||
|
int('1100', 2),
|
||||||
|
int('0110', 2),
|
||||||
|
int('0011', 2),
|
||||||
|
int('1001', 2)
|
||||||
|
)
|
||||||
|
|
||||||
|
medio_paso = {
|
||||||
|
int('1000', 2),
|
||||||
|
int('1100', 2),
|
||||||
|
int('0100', 2),
|
||||||
|
int('0110', 2),
|
||||||
|
int('0011', 2),
|
||||||
|
int('0001', 2),
|
||||||
|
int('1001', 2),
|
||||||
|
}
|
||||||
|
|
||||||
|
SLEEP_MS = 500
|
||||||
|
DELAY_MS = 120
|
||||||
|
|
||||||
|
sentido = True
|
||||||
|
config - 1
|
||||||
|
|
||||||
|
|
||||||
|
bobinas = list()
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
for i in motor_pin:
|
||||||
|
bobinas.append(i)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if not button_1.value():
|
||||||
|
utime.sleep_ms(self.DEBOUNCE_MS)
|
||||||
|
print("btn1")
|
||||||
|
pin_green.value(not pin_green.value())
|
||||||
|
motor_int_1.value(not motor_int_1.value())
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not button_2.value():
|
||||||
|
utime.sleep_ms(self.DEBOUNCE_MS)
|
||||||
|
print("btn2")
|
||||||
|
pin_white.value(not pin_white.value())
|
||||||
|
motor_int_2.value(not motor_int_2.value())
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not button_3.value():
|
||||||
|
utime.sleep_ms(self.DEBOUNCE_MS)
|
||||||
|
print("btn3")
|
||||||
|
pin_yellow.value(not pin_yellow.value())
|
||||||
|
motor_int_3.value(not motor_int_3.value())
|
||||||
|
continue
|
||||||
|
|
||||||
|
def main():
|
||||||
|
program = taller3()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if not self.button_2.value():
|
||||||
|
utime.sleep_ms(self.DEBOUNCE_MS)
|
||||||
|
print("btn2")
|
||||||
|
self.pin_white.value(not self.pin_white.value())
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not self.button_3.value():
|
||||||
|
utime.sleep_ms(self.DEBOUNCE_MS)
|
||||||
|
print("btn3")
|
||||||
|
self.pin_yellow.value(not self.pin_yellow.value())
|
||||||
|
continue
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
from machine import Pin
|
||||||
|
import utime
|
||||||
|
|
||||||
|
class taller3:
|
||||||
|
DEBOUNCE_MS = 100
|
||||||
|
SLEEP_MS = 100
|
||||||
|
DELAY_MS = 120
|
||||||
|
|
||||||
|
LOW = 0
|
||||||
|
HIGH = 1
|
||||||
|
|
||||||
|
button_1 = Pin(13, Pin.IN, Pin.PULL_UP)
|
||||||
|
button_2 = Pin(12, Pin.IN, Pin.PULL_UP)
|
||||||
|
button_3 = Pin(14, Pin.IN, Pin.PULL_UP)
|
||||||
|
button_4 = Pin(27, Pin.IN, Pin.PULL_UP)
|
||||||
|
|
||||||
|
In1 = Pin(5, Pin.OUT, value = 0)
|
||||||
|
In2 = Pin(18, Pin.OUT, value = 0)
|
||||||
|
In3 = Pin(19, Pin.OUT, value = 0)
|
||||||
|
In4 = Pin(21, Pin.OUT, value = 0)
|
||||||
|
|
||||||
|
motor_pin = {In1, In2, In3, In4}
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
while True:
|
||||||
|
utime.sleep_ms(300)
|
||||||
|
if not self.button_1.value():
|
||||||
|
print("btn1")
|
||||||
|
if not self.button_2.value():
|
||||||
|
print("btn2")
|
||||||
|
if not self.button_3.value():
|
||||||
|
print("btn3")
|
||||||
|
if not self.button_4.value():
|
||||||
|
print("btn4")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
program = taller3()
|
||||||
|
program.run()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
from machine import ADC
|
||||||
|
from utime import sleep
|
||||||
|
def main():
|
||||||
|
# True: Raspberry Pi Pico
|
||||||
|
# False: NodeMCU ESP8266
|
||||||
|
placa = False
|
||||||
|
|
||||||
|
if placa:
|
||||||
|
potenciometro = ADC(26) #Raspberry Pi Pico ADC0
|
||||||
|
else:
|
||||||
|
# ESP32
|
||||||
|
potenciometro = ADC(34)
|
||||||
|
# potenciometro = ADC(0) #NodeMCU8266v3 ADC0
|
||||||
|
factor_10 = 3.3 / (1023) #Se puede leer con read()
|
||||||
|
|
||||||
|
factor_16 = 3.3 / (65535)
|
||||||
|
|
||||||
|
while True:
|
||||||
|
|
||||||
|
if not placa: #NodeMCU ESP8266
|
||||||
|
bits = potenciometro.read();
|
||||||
|
volts_10 = bits * factor_10
|
||||||
|
print('\nValor en 10 bits: {}, y en volts: {}'.format(bits, volts_10))
|
||||||
|
|
||||||
|
bits_16 = potenciometro.read_u16();
|
||||||
|
volts_16 = bits_16 * factor_16
|
||||||
|
|
||||||
|
|
||||||
|
print('Valor en 16 bits: {}, y en volts: {}'.format(bits_16, volts_16))
|
||||||
|
sleep(1)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
|
@ -23,6 +23,62 @@
|
||||||
`"MicroPython family" = "ESP32"`
|
`"MicroPython family" = "ESP32"`
|
||||||
|
|
||||||
`"variant" = "Espressif ESP32 / WROOM"`
|
`"variant" = "Espressif ESP32 / WROOM"`
|
||||||
|
|
||||||
`"version" = "1.26.1`
|
`"version" = "1.26.1`
|
||||||
|
|
||||||
|
|
||||||
|
## Thonny
|
||||||
|
|
||||||
|
### Template
|
||||||
|
```py
|
||||||
|
from machine import Pin
|
||||||
|
import utime
|
||||||
|
|
||||||
|
LOW = 0
|
||||||
|
HIGH = 1
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("template")
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
```
|
||||||
|
|
||||||
|
### Pin
|
||||||
|
|
||||||
|
#### Led
|
||||||
|
|
||||||
|
```py
|
||||||
|
# (High) status
|
||||||
|
led.value(1)
|
||||||
|
led.on()
|
||||||
|
|
||||||
|
# (Low) status
|
||||||
|
led.value(0)
|
||||||
|
led.off()
|
||||||
|
|
||||||
|
|
||||||
|
led_placa = Pin(2, Pin.OUT, value = 1)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Button
|
||||||
|
|
||||||
|
```py
|
||||||
|
boton_down = Pin(4, Pin.IN, Pin.PULL_DOWN)
|
||||||
|
boton_up = Pin(4, Pin.IN, Pin.PULL_UP)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Time
|
||||||
|
|
||||||
|
```py
|
||||||
|
import utime
|
||||||
|
|
||||||
|
utime.sleep(<segundos>)
|
||||||
|
|
||||||
|
utime.sleep_ms(<milisegundos>)
|
||||||
|
|
||||||
|
utime.sleep_us(<microsegundos>)
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ def main():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if button_up.value() == 1:
|
if button_up.value() == 1:
|
||||||
pin_board.value(not pin_placa.value())
|
pin_board.value(not pin_board.value())
|
||||||
sleep(1)
|
sleep(1)
|
||||||
if button_up2.value() == 1:
|
if button_up2.value() == 1:
|
||||||
pin_board.value(not pin_placa.value())
|
pin_board.value(not pin_board.value())
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue