I'm building an image printer using my ev3 set and several more pieces, as a project to keep me occupied while I'm stuck at home.
Here's how it looks:
I've done the build part, the way I've chosen to do this is by converting my image to binary (B/W) and reading each number in my binary array, then drawing a dot if there's a 1 or skipping the dot if there's a 0.
I'm using Ev3 Python, as that's the language I know and I found it easiest to program in, but after I created my program my brick doesn't seem to process it properly and my brick weirdly starts to draw dots in the same spot, then instantly starts to move its top arm in the same direction for much longer than its programmed to, then sort of just stops its paper-moving wheels and starts doing more weird movements.
I tested my program's values before I wrote the program, it can draw 2 dots in a line correctly spaced out, but it starts doing weird things when I give it a whole line of data to draw.
Here's my code:
#!/usr/bin/env pybricks-micropython from pybricks.hubs import EV3Brick from pybricks.ev3devices import Motor from pybricks.parameters import Port import time ev3 = EV3Brick() LR = Motor(Port.C) UD = Motor(Port.D) FB = Motor(Port.B) def pendown(): UD.run_target(40, 40) def penup(): UD.run_target(40, -40) def nextline(): LR.run_target(40, 300) FB.run_target(40, 30) def nextdot(): LR.run_target(40, -30) byteval = ''' 0000000000100100001001000000000000100100001111000000000000000000 ''' bytevalues = list(byteval) # wait a bit time.sleep(5) # define grid limit x_limit = 8 y_limit = 8 number_of_cells = x_limit * y_limit; x = 0 # scan grid and perform action depending on cell value while x < (number_of_cells): z = bytevalues[x] if z == '1': #draw a dot pendown() penup() nextdot() elif z == '0': #go to next cell value nextdot() x+=1 if (x % x_limit) == 0: #go to next line nextline()
[I'm using an 8-Bit happy face as my image]
I don't know why this weird movement is happening, I don't think it should, please help me with this issue.