קורס RB07 רובטיקס בלוקס 016 : מבוא לפייתון פיתוח רובוטיקה
יעד : תרגול משפטי תנאי ,לולאה, בניית תוכנה לרובט , מרכז מסה
איך מפתחים בינה מלאכותית
תרגיל כיתה מספר 1
1. הפעל את התוכנית הבאה במיקרו פייתון
2. הסבר כל שורה מה עושה – אם אינך יודע פנה למדריך
3. הוסף לקוד התוכנה – שלחוצים על מקש 9 כותב GRIP CLOSE
4. הוסף לקוד התוכנה – שלוחצים על מקש 7 כותב GRIP OPEN
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# Load the machine module in order to access the hardware # www.robotronix.co.il robotics blocks # חוג רובוטיקה רובוטיקס בלוקס לימוד מיקרופייתון # https://robotronix.co.il/%d7%a8%d7%95%d7%91%d7%95%d7%98%d7%a8%d7%95%d7%a0%d7%99%d7%a7%d7%a1-%d7%9b%d7%9c%d7%9c%d7%99/%d7%97%d7%95%d7%92-%d7%a8%d7%95%d7%91%d7%95%d7%98%d7%99%d7%a7%d7%94-%d7%a1%d7%a4%d7%a8%d7%99%d7%99%d7%aa-%d7%93%d7%95%d7%92%d7%9e%d7%90%d7%95%d7%aa-%d7%9e%d7%99%d7%a7%d7%a8%d7%95-%d7%a4%d7%99/ import machine # Create the uart object in port 2 # Rx=GPIO 16, Tx=GPIO 17 uart = machine.UART(1, 115200) # Create a global variable to hold the receive data in serial strMsg = '' print("start robot program") # This is the main loop while True: # if there is character in receive serial buffer if uart.any() > 0: # Read all the character to strMsg variable ch = uart.read() # Debug print to REPL if '\r' in ch: print("Fire") if '8' in ch: print("Move forward") if '2' in ch: print("Move back") if '4' in ch: print("Turn left") if '6' in ch: print("Turn right") |
השתמש בקוד דוגמא להוספה :
5. הוסף שלוחצים על מקש 8 ילדק אור ירוק
6. הוסף שלוחצים על מקש 2 ילדק אור ירוק פעמים ויכבה
7. הסוף שלוחצים על מקש 2 ישמע צליל פיב פיב .
קוד דוגמא להדלקת לד וכיבוי
קוד דוגמא להדלקתבאזר וכיבוי
https://wokwi.com/projects/359498525537638401