0% found this document useful (0 votes)
2 views

Lab 4

This document covers two main parts: SSH and Timers. It explains how to enable and use SSH on a Raspberry Pi for remote access, including exercises for creating and modifying Python programs. Additionally, it discusses the use of timers for generating operations based on events, with exercises related to blinking LEDs and modifying intervals using timers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab 4

This document covers two main parts: SSH and Timers. It explains how to enable and use SSH on a Raspberry Pi for remote access, including exercises for creating and modifying Python programs. Additionally, it discusses the use of timers for generating operations based on events, with exercises related to blinking LEDs and modifying intervals using timers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

LABORATORY 4: SSH and Timers

Part 1: SSH.
Theory Concepts:
SSH comes from “Secure Shell” and is a remote Administration protocol that
enables the control of a remote device.

Ssh needs a hostname/ip, port, user credential and password.


We need to enable ssh on our raspberry Pi:
After enabling ssh on the raspberry pi we can access to this device remotely using
the ip address it has and the user password. To do this a common network
between the raspberry and the computer is needed.
We can follow the next steps to connect and disconnect using ssh.
1. Enable Raspberry PI’s SSH from Raspberry Pi configuration -> Interfaces
-> Enable SSH
2. It’s recommended to change the Raspberry password using the command
sudo raspi-config.
3. Raspberry PI’s IP can be showed using the command hostname -I.
4. Use the command ssh pi@[raspberry_IP] in Ubuntu like for example: ssh
[email protected].
5. Usually after step 4 is needed to put the Raspberry password and
username.
6. To end SSH communication, in the terminal type “exit”.
Which is the default port ssh uses?
Can we connect to our raspberry pi using different devices than our computers
like our smartphones? If so, how can we do it?
Exercises:
• Using SSH create a new folder in your raspberry pi with the name “lab4”,
then make a python file inside the folder with the name “buzzer.py”
• Generate a python program in your computer that makes a buzzer sound
when a button is pressed.
• Using SSH modify the previous program to make the buzzer sound when
a button is pressed and stop when a second button is pressed.
• Create a led sequence that has a variable time interval between states.
Make the program in a way that it can get ssh modifications without
stopping the execution. Tip: Modify a txt file with ssh and read the file
values in the main program from Raspberry Pi.
Can you program in python using SSH from your computer?
Investigate how VSCode can manage to work remotely using the ‘Remote-
SSH extension’.

Part 2: Timers.
▸ Timers are used to generate operations according to some events during
the time.
▸ Generally, we will generate interruptions to the main routine when a timer
is executed.
▸ We can use delay to interrupt all the program execution and timers to
change the main routine for a sub routine.

We must set the timer to work correctly. For that, is needed to define a Frequence
Sample or FS that works as a Prescaler for our timer. The following formula can
help us to select the proper FS:

timerFreq=clockfreq/FS
With the FS selected we have to start the processor interruption and then enable
the timer:
The timer uses an external function to execute the sub routine. This routine will
stop the main routine and depending on if the timer is periodic, or one shot will
keep executing.

We must declare the timer function in the startup file of the project.
This process will help us to generate a timer sequence and use it to make an
interruption to the main process.
Exercises:
• Blink the user LED PN1 with timer interruptions in the Tiva. Initially blink
the LED every second, then modify the code to blink the LED every 2
seconds and finally change the code to blink the LED every 5 seconds.
• Make a decimal sequence with the user leds that changes each 2 seconds.
• Modify the previous excercise to change the interval to 1 and 0,5 seconds
when a user switch is pressed.
• Modify the binary counter exercise from lab 3 to use timers, each
sequence should change without buttons and in a 1.5 second interval.
Then add a new functionality, when a button is pressed change the time
interval to 3 seconds.

You might also like