In your terminal type the command: sudo pip3 install adafruit-ampy .
00:00
You will be asked to enter your user's password.

If you're on a Raspberry Pi Computer, the default password for the user called pi is the password raspberry.
00:00
Once installed you'll see the following in your terminal.
00:00
To test that Ampy is installed, simply type ampy. You'll then see instructions on how to use ampy.
00:00
In the text editor of your choice, create a file called main.py with the following code.
00:00
The led = Pin(25, Pin.OUT) will be familiar to us. Here we're creating a new pin variable and using GPIO 25, and setting it as an output
00:00
We're now creating a new variable called tim, which is a Timer object. We'll use this a bit later.
00:00
In this block of code we're creating a function in Python. You can think of a function as a predefined snippet of code that we can call later.
00:00
The global keyword before the led variable, allows us to read and write the global led variable both inside and outside the tick function.
00:00
Pin objects have a method called toggle, that changes the current value of the pin. 

If the pin is on, the pin will then be turned off. If the pin is off, it'll be turned on.
00:00
The Timer object has a method called init which needs three aguments, freq, mode and callback.

The freq argument is the number of times per second (frequency in hertz) we want the Timer object to call code in the callback.

The mode argument specifies how the timer is going to run. Setting Timer.PERIODIC tells the Pico that timer runs periodically at the configured frequency of the channel (in our case 2.5 times a second).

The callback is the function that we want to run. In our case we're calling the tick() function, which toggles our LED on and off. 
00:00
To copy the main.py python file across to our Pico Board we use the command: ampy -p /dev/tty.usbmodem0000000000001 put ~/Desktop/main.py
00:00
Breaking down the command: ampy is the program we're running.
00:00
The -p /dev/tty.usbmodem0000000000001 part tells ampy what port our Raspberry Pi Pico is on.
00:00
The put is the command we want to run, in this case we want ampy to put the file onto our Raspberry Pi Pico.
00:00
The ~/Desktop/main.py is the path to the file that we want to copy. In my case I have the file saved on my computer's Desktop folder. If you had a file called main.py in your home directory, the path would be ~/main.py .
00:00
Once you've copied the file across, the Raspberry Pi Pico won't immediately run it. You'll need to disconnect the Pico and connected it again.
00:00
Once you disconnect and reconnect the power to your Pico, the LED will start to blink
00:00
main.py
xxx
Terminal
screen /dev/tty.usbmodem0000000000001 115200
>>> led = Pin(25, Pin.OUT)
>>> from machine import Pin
Breadboard
Breadboard
Mark
© 2022 Chick Commerce Pty Ltd