Bapt G
Published © GPL3+

First Steps with M.A.R.K

M.A.R.K is a robot designed for learning about Artificial Intelligence. Easy to assemble and use, I had a chance to test him.

BeginnerProtip2 hours81
First Steps with M.A.R.K

Things used in this project

Hardware components

seeed M.A.R.K
×1

Software apps and online services

Codecraft from Tinkergen
IDE for graphical coding that generates Python code for several products, such as M.A.R.K

Story

Read more

Code

Python code generated by the graphical IDE

Python
# generated by Codecraft for cyberEye
# codes make you happy
from gpio import *
from modules import ws2812
import utime
from maix_motor import Maix_motor
import time
from camera import *

ws2812_13 = ws2812(fm.board_info.D[13],5,2,3)

Face = FaceDetection()

def start_handler_0():
    pass
    ws2812_13.set_led(1, (0, 255, 255))
    ws2812_13.display()
    ws2812_13.set_led(0, (0, 255, 255))
    ws2812_13.display()
    utime.sleep_ms(250);
    ws2812_13.set_led(1, (255, 0, 0))
    ws2812_13.display()
    ws2812_13.set_led(0, (255, 0, 0))
    ws2812_13.display()
    utime.sleep_ms(250);
    ws2812_13.set_led(1, (0, 0, 0))
    ws2812_13.display()
    ws2812_13.set_led(0, (0, 0, 0))
    ws2812_13.display()
    Maix_motor.servo_angle(2, 135)
    while True:
        time.sleep(0.02)
        if not Face.getFaceDetectionResult():
            Maix_motor.motor_motion(1, 3, 0)
        else:
            Maix_motor.motor_run(0, 0, 0)
            ws2812_13.set_led(1, (0, 255, 255))
            ws2812_13.display()
            ws2812_13.set_led(0, (0, 255, 255))
            ws2812_13.display()
            utime.sleep_ms(500);
            ws2812_13.set_led(1, (0, 0, 0))
            ws2812_13.display()
            ws2812_13.set_led(0, (0, 0, 0))
            ws2812_13.display()
            utime.sleep_ms(100);
            if Face.getFaceDetectionProperty(1,'x') > 100:
                ws2812_13.set_led(0,(0, 255, 255))
                ws2812_13.display()
                Maix_motor.motor_motion(1, 3, 0)
            else:
                ws2812_13.set_led(1,(0, 255, 255))
                ws2812_13.display()
                Maix_motor.motor_motion(1, 4, 0)
            while not (Face.getFaceDetectionProperty(1,'x') < 90 or Face.getFaceDetectionProperty(1,'x') > 110):
                time.sleep(0.02)
                lcd_display_string_row(Face.getFaceDetectionProperty(1,'x'), 1)
            Maix_motor.motor_run(0, 0, 0)
            ws2812_13.set_led(1, (0, 255, 255))
            ws2812_13.display()
            ws2812_13.set_led(0, (0, 255, 255))
            ws2812_13.display()
            utime.sleep_ms(500);
            Maix_motor.motor_motion(1, 1, 0)
            while not get_ultrasonic_distance(4) < 5:
                time.sleep(0.02)
            definition_fun()

def definition_fun():
    pass
    Maix_motor.motor_run(0, 0, 0)
    ws2812_13.set_led(1, (0, 0, 0))
    ws2812_13.display()
    ws2812_13.set_led(0, (0, 0, 0))
    ws2812_13.display()
    while True:
        time.sleep(0.02)

lcd.clear()
start_handler_0()

Credits

Bapt G

Bapt G

2 projects • 0 followers

Comments