I have some weird problems with my pi, when I run this code:
[code]import time
import explorerhat as eh
import pygame
from pygame.locals import *
def Stop():
eh.motor.one.forwards(0)
eh.motor.two.forwards(0)
def TurnRight():
eh.motor.one.forwards(100)
eh.motor.two.forwards(0)
def TurnLeft():
eh.motor.one.forwards(0)
eh.motor.two.forwards(100)
def Forwards():
eh.motor.one.forwards(100)
eh.motor.two.forwards(100)
def Backwards():
eh.motor.one.backwards(100)
eh.motor.two.backwards(100)
pygame.init()
## pygame.key.set_repeat(100, 100)
screen = pygame.display.set_mode((200,200))
print ('Let's start!')
while 1:
for event in pygame.event.get():
if (event.type == KEYDOWN):
if (event.key == K_w):
Forwards()
if (event.key == K_s):
Backwards()
if (event.key == K_a):
TurnLeft()
if (event.key == K_d):
TurnRight()
if (event.key == K_UP):
Forwards()
if (event.key == K_DOWN):
Backwards()
if (event.key == K_LEFT):
TurnLeft()
if (event.key == K_RIGHT):
TurnRight()
if event.type == pygame.KEYUP:
Stop()
[/code]
The pi crashes for some weird reason. A day ago it did it all fine, but somehow it stops when I press enter. Maybe some of you smart guys can tell the N00B how to fix it. Thanks