Article Index
ESP32PythonPrograms
Chapter 3
Chapter 4
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Chapter 13
Chapter 14
Chapter 15
Chapter 16
Chapter 17
Chapter 18
All Pages
Page 3 of 16
Page 50
from machine import Pin
pin = Pin(6, Pin.OUT)
while True:
pin.value(1)
pin.value(0)
Page 51
from machine import Pin
def flash():
pin = Pin(2, Pin.OUT)
while True:
pin.value(1)
pin.value(0)
flash()
Page 51
from machine import Pin
@micropython.native
def flash():
pin = Pin(2, Pin.OUT)
while True:
pin.value(1)
pin.value(0)
flash()
Page 52
from machine import Pin
import time
pin = Pin(2, Pin.OUT)
while True:
pin.value(1)
time.sleep(0.5)
pin.value(0)
time.sleep(0.5)
Page 53
from machine import Pin
import time
pin = Pin(2, Pin.OUT)
while True:
pin.value(1)
time.sleep_us(10)
pin.value(0)
time.sleep_us(10)
Page 53
from machine import Pin
import time
pin = Pin(2, Pin.OUT)
n = 10
while True:
for i in range(n):
pass
pin.value(1)
for i in range(n):
pass
pin.value(0)
Page 54
from machine import Pin
import time
pin = Pin(2, Pin.OUT)
n = 5
while True:
t = time.ticks_add(time.ticks_us(), 1000)
pin.value(1)
for i in range(n):
pass
while time.ticks_us() < t:
pass
pin.value(0)
Page 56
import time
from time import sleep
import esp32
from machine import Pin
import machine
pin = Pin(2,Pin.OUT,value=0)
buf = bytearray(b"\x55\x55")
print(buf)
machine.bitstream(pin,0,(80,90,100,110),buf)
Page 58
import esp32
from machine import Pin
import machine
pin=Pin(2,Pin.OUT,value=0)
rmt=esp32.RMT(0,pin=pin)
rmt.write_pulses((1000,400,200,300,200,300),1)
Page 59
from machine import Pin
pin1 = Pin(2, Pin.OUT)
pin2 = Pin(4, Pin.OUT)
while True:
pin1.value(1)
pin2.value(0)
pin1.value(0)
pin2.value(1)
Page 61
from machine import Pin
import machine
def gpio_set(value, mask):
machine.mem32[0x3FF44004] = machine.mem32[0x3FF44004] & ~mask | value & mask
pin = Pin(2, Pin.OUT)
pin = Pin(4, Pin.OUT)
value1 = 1 << 2 | 0 << 4
value2 = 0 << 2 | 1 << 4
mask = 1 << 2 | 1 << 4
while True:
gpio_set(value1, mask)
gpio_set(value2, mask)
<< Prev
Next >>
Main Menu
Home
Books
Programming the ESP32 in MicroPython
Programmer’s Python: Async
Programmer's Python: Everything is an Object 2e
Programmer’s Python: Everything is Data
Programming The Raspberry Pi Pico/W In C 2ed
Programming The Raspberry Pi Pico/W In MicroPython Second Edition
Raspberry Pi IoT in C Third Edition
Raspberry Pi IoT In C Using Linux Drivers 2e
Raspberry Pi IoT In Python Using GPIO Zero 2e
Android Programming In Java
Raspberry Pi IoT In Python Using Linux Drivers 2e
Android Programming Kotlin
Applying C For The IoT With Linux
Deep C#
Explore Intel Edison
Financial Functions
Fundamental C: Getting Closer To The Machine
JavaScript Async
JavaScript Bitmap Graphics With Canvas
JavaScript Jems
Just JavaScript
Just jQuery: Events, Async & AJAX
Just jQuery: The Core UI
Micro:bit IoT In C Second Edition
Programmer's Guide To Kotlin 3ed
The Programmer’s Guide To Theory
The Trick Of The Mind
Master the Raspberry Pi Pico in C: WiFi with lwIP & mbedtls
Extending & Embedding Python Using C
Deep C Dives: Adventures in C
Programming The ESP32 In C Using The Espressif IDF
Programming The ESP32 In C Using The Arduino Library
Author's Pages
Ian Elliot
Mike James
Harry Fairhead
Contact Us