Introduction
The Raspberry Pi made physical computing and programming accessible to many -- it is relatively inexpensive, and almost anyone could simply connect a monitor, keyboard, and mouse to get started. Python is an easy to start with high-level language, and it is an integral part of the Raspberry Pi's operating system.Â
In this guide, we'll show you how to get started with the Thonny IDE, learn about basic data types and control flow statements that are readily used when working with sensors and actuators on the Raspberry Pi.
Complete this guide to get started with Python programming on the Raspberry Pi.
In this guide, we'll show you how to get started with the Thonny IDE, learn about basic data types and control flow statements that are readily used when working with sensors and actuators on the Raspberry Pi.
Complete this guide to get started with Python programming on the Raspberry Pi.
Tools
-
-
-
-
-
-
-
-
-
-
-
-
a = 15 if a > 20: print("a is larger than 20")
-
import RPi.GPIO as GPIO import Adafruit_DHT sensor = Adafruit_DHT.DHT11 LED=40 GPIO.setmode(GPIO.BOARD) GPIO.setup(LED,GPIO.OUT) #Red LED GPIO.output(LED,GPIO.LOW) humidity, temperature = Adafruit_DHT.read_retry(sensor, gpio) if humidity is not None and temperature is not None: print('Temp={0:0.1f}*C Humidity={1:0.1f}%'.format(temperature, humidity)) else: print('Failed to get reading. Try again!') if temperature > 30: GPIO.output(LED, GPIO.HIGH) else: GPIO.output(LED, GPIO.LOW) GPIO.cleanup()
-
for x in range (0, 5): print "hello"
-
import RPi.GPIO as GPIO import time LED = 18 GPIO.setmode(GPIO.BCM) GPIO.setup(LED, GPIO.OUT) while (True): GPIO.output(LED, True) time.sleep(1) GPIO.output(LED, False) time.sleep(1)
-
import RPi.GPIO as GPIO import time LED = 18 GPIO.setmode(GPIO.BCM) GPIO.setup(LED, GPIO.OUT) i = 0 while (True): print("Value of i is now ", i) GPIO.output(LED, True) time.sleep(1) GPIO.output(LED, False) time.sleep(1) i += 1 if i > 10: break
-