KB2040 serial

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
solidairsound
 
Posts: 1
Joined: Sat Jan 21, 2023 2:54 pm

KB2040 serial

Post by solidairsound »

I have a seesaw rotary encoder device connected to a KB2040 (because it was included in my order for free), which i want so send '7,4,1,H' for each positive rotation increment and '8,4,1,H' for each negative rotational increment. The software which this is send to must receive it as such (without apostrophes). Code now:

Code: Select all

import board
import busio
from rainbowio import colorwheel
from adafruit_seesaw import seesaw, neopixel, rotaryio, digitalio

uart = busio.UART(board.TX, board.RX, baudrate=19200)

i2c = board.I2C()
seesaw = seesaw.Seesaw(i2c, 0x36)

encoder = rotaryio.IncrementalEncoder(seesaw)
seesaw.pin_mode(24, seesaw.INPUT_PULLUP)
switch = digitalio.DigitalIO(seesaw, 24)
last_position = -1

panplus = b'7,4,1,H'
panminus = b'8,4,1,H'

while True:
    data = uart.read(7)
    position = -encoder.position
    if data is not None:
        if position > last_position:
            uart.write(panplus)
        if position < last_position:
            uart.write(panminus)
        last_position = position
    print(data)
if possible i would like to send the serial data over the devices usb connection (without the need for a usb-ttl device, although i have one lying around).
the repl shows correct data being written, however the software that i want to talk to is not responding. When using a terminal emulator it does respond the commands (in text).

Any suggestions?

User avatar
adafruit_support_carter
 
Posts: 29473
Joined: Tue Nov 29, 2016 2:45 pm

Re: KB2040 serial

Post by adafruit_support_carter »

if possible i would like to send the serial data over the devices usb connection
Check out the data serial option described here:
https://learn.adafruit.com/customizing- ... ta-3096590

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”