Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
Greta Galli
Created December 26, 2019 © GPL3+

Cyborgr3 - cybernetic hand

Cyborgr3 is a cybernetic hand made with Lego Mindstorms EV3. It is thought for people that need an extra hand.

AdvancedShowcase (no instructions)3 days96
Cyborgr3 - cybernetic hand

Things used in this project

Hardware components

Mindstorms EV3 Programming Brick / Kit
LEGO Mindstorms EV3 Programming Brick / Kit
×1

Software apps and online services

lego mindstorms ev3 home edition

Story

Read more

Custom parts and enclosures

virtual image

this is the virtual image of the project made with LDD

Schematics

connection

This image show the connection within Mindstorms and Alexa

Code

cyborgr3.txt

Java
It is the code for the cybernetic hand
import os
import sys
import time
import logging

from ev3dev2.sound import Sound
from ev3dev2.led import Leds
from ev3dev2.motor import OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D, LargeMotor

from agt import AlexaGadget

# set logger to display on both EV3 Brick and console
logging.basicConfig(level=logging.INFO, stream=sys.stdout, format='%(message)s')
logging.getLogger().addHandler(logging.StreamHandler(sys.stderr))
logger = logging.getLogger(__name__)


class MindstormsGadget(AlexaGadget):
    

    def __init__(self):
        
        super().__init__()

        self.leds = Leds()
        self.sound = Sound()
        self.thumb_motor = LargeMotor(OUTPUT_A)
        self.index_motor = LargeMotor(OUTPUT_B)
        self.middle_motor = LargeMotor(OUTPUT_C)
        self.ring_motor = LargeMotor(OUTPUT_D)

        self.bpm = 0
        self.trigger_bpm = "off"

    def on_connected(self, device_addr):
       
        self.leds.set_color("LEFT", "GREEN")
        self.leds.set_color("RIGHT", "GREEN")
        logger.info("{} connected to Echo device".format(self.friendly_name))

    def on_disconnected(self, device_addr):
        
        self.leds.set_color("LEFT", "BLACK")
        self.leds.set_color("RIGHT", "BLACK")
        logger.info("{} disconnected from Echo device".format(self.friendly_name))

    def on_alexa_gadget_statelistener_stateupdate(self, directive):
        
        color_list = ['BLACK', 'AMBER', 'YELLOW', 'GREEN']
        for state in directive.payload.states:
            if state.name == 'open hand':

                if state.value == 'active':
                    self.thumb_motor.run_timed(speed_sp=25, time_sp=1000)
                    self.index_motor.run_timed(speed_sp=25, time_sp=1000)
                    self.middle_motor.run_timed(speed_sp=25, time_sp=1000)
                    self.ring_motor.run_timed(speed_sp=25, time_sp=1000)

            if state.name == 'close hand':

                if state.value == 'active':
                    self.thumb_motor.run_timed(speed_sp=-25, time_sp=1000)
                    self.index_motor.run_timed(speed_sp=-25, time_sp=1000)
                    self.middle_motor.run_timed(speed_sp=-25, time_sp=1000)
                    self.ring_motor.run_timed(speed_sp=-25, time_sp=1000)


if __name__ == '__main__':

    MindstormsGadget().main()

    # Set LCD font and turn off blinking LEDs
    os.system('setfont Lat7-Terminus12x6')
    gadget.leds.set_color("LEFT", "BLACK")
    gadget.leds.set_color("RIGHT", "BLACK")

    # Startup sequence
    gadget.sound.play_song((('C4', 'e'), ('D4', 'e'), ('E5', 'q')))
    gadget.leds.set_color("LEFT", "GREEN")
    gadget.leds.set_color("RIGHT", "GREEN")

    # Gadget main entry point
    gadget.main()

    # Shutdown sequence
    gadget.sound.play_song((('E5', 'e'), ('C4', 'e')))
    gadget.leds.set_color("LEFT", "BLACK")
    gadget.leds.set_color("RIGHT", "BLACK")

Credits

Greta Galli

Greta Galli

4 projects • 21 followers
I am an eighteen italian girl and I like robotics and mechatronics. I've create a cybernetic hand only with Lego. Enjoy :)

Comments