MicroPython-Hack-first-script

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Introduction

Let’s jump right in and get a Python script running on the pyboard. After all, that’s what it’s all about!

Connecter le PyBoard

Connect your pyboard to your PC (Windows, Mac or Linux) with a micro USB cable. There is only one way that the cable will connect, so you can’t get it wrong.

{{{2}}}
Crédit: MicroPython micropython.org

When the pyboard is connected to your PC it will power on and enter the start up process (the boot process). The green LED should light up for half a second or less, and when it turns off it means the boot process has completed.

Ouvrir le lecteur USB du PyBoard

Your PC should now recognise the pyboard. It depends on the type of PC you have as to what happens next:

  • Windows: Your pyboard will appear as a removable USB flash drive. Windows may automatically pop-up a window, or you may need to go there using Explorer.
    Windows will also see that the pyboard has a serial device, and it will try to automatically configure this device. If it does, cancel the process. We will get the serial device working in the next tutorial.
  • Mac: Your pyboard will appear on the desktop as a removable disc. It will probably be called “NONAME”. Click on it to open the pyboard folder.
  • Linux: Your pyboard will appear as a removable medium. On Ubuntu it will mount automatically and pop-up a window with the pyboard folder. On other Linux distributions, the pyboard may be mounted automatically, or you may need to do it manually. At a terminal command line, type lsblk to see a list of connected drives, and then mount /dev/sdb1 (replace sdb1 with the appropriate device). You may need to be root to do this.

Okay, so you should now have the pyboard connected as a USB flash drive, and a window (or command line) should be showing the files on the pyboard drive.

The drive you are looking at is known as /flash by the pyboard, and should contain the following 4 files:

  • boot.py - this script is executed when the pyboard boots up. It sets
    up various configuration options for the pyboard.
  • main.py - this is the main script that will contain your Python program.
    It is executed after boot.py.
  • README.txt - this contains some very basic information about getting started with the pyboard.
  • pybcdc.inf - this is a Windows driver file to configure the serial USB device. More about this in the next tutorial.

Editer main.py



Source: Running your first script écrit par/written by Damien P.George

Traduit par Meurisse D. pour MCHobby.be - Translated by Meurisse D. for MCHobby.be

Traduit avec l'autorisation de micropython.org - Translated with the authorisation of micropython.org

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.