![]() ![]() Utime.sleep(1) # REQUIRED to allow the SerLCD to initialise, code will not run on boot without this delay #i2c.writeto(114, out_string) #print text to display #i2c.writeto(114, '\x2B') #change backlight RGB values #i2c.writeto(114, '\x7C') #enter settings mode I2c.writeto(114, out_string) #print text to display Out_string = str(round(temperature, 1)) "\xDFC" #construct string to print Temperature = 27 - (reading - 0.706)/0.001721 #convert voltage value to degrees celsius Reading = adc.read_u16() * conversion_factor # read temperature sensor I2c.writeto(114, '\x00') #set blue value to 170/255Īdc = machine.ADC(4) #setup analogue-to-digital converter on channel 4 for temperature sensorĬonversion_factor = 3.3 / (65535) # convert raw value to voltage value I2c.writeto(114, '\x2B') #change backlight RGB values I2c.writeto(114, '\x7C') #enter settings mode Thonny run without saving full#However, most IDEs require a graphical interface to use, which means you will need to be on the full desktop version of Raspbian.I2c=machine.I2C(0,sda=sda, scl=scl, freq=400000) IDEs offer a number of benefits including syntax highlighting, code completion, one-click running, debugging hints, etc. Some users prefer to use an integrated development environment (IDE) when developing code. You are welcome to continue working through this guide using a text editor and command line. nano, vim, emacs, Midnight Commander, Leafpad, etc.), save it, and then run it from the terminal with the command python. The simplest way to create Python programs is to write your code in a text editor (e.g. py suffix is also necessary when making modules, which we'll cover later. py, you will know that it contains Python code. However, it can be very helpful to keep your files organized so that when you see a file ending in. ![]() py is not required for the interpreter to run the code found inside. py, the Python interpreter will run the commands found in the file without giving you an interactive session. To summarize what we just did, you can use the python command on its own to begin an interactive interpreter session that allows you to type commands in real time. Note: In case you were wondering, I am clearing my terminal between screenshots with the clear command. Once you press enter, you should see the phrase Hello, World! repeated back to you. Type the following command: language:bash You should be presented with a different command prompt, consisting of 3 greater-than signs >. Getting Started with the Interpreterįrom a terminal, enter the following commend to start the Python interpreter: language:bash If you are curious about where the phrase "Hello, World!" comes from, this Wikipedia article gives a brief yet fascinating history. This will show you two of the main ways to interact with Python. We'll do this first from the interpreter and then we'll create a file and run it as a program. ![]() To start, we'll tell Python to print the phrase, "Hello, World!" to the terminal. This will allow us to test out commands one line at a time! In fact, we can even run the interpreter in what's known as interactive mode. translate our program into machine code) in order to run our program. This means that we don't need to run a separate compile step (i.e. One of the coolest features of Python is that it is an interpreted language (OK, in reality, Python scripts are first compiled to some bytecode, and that bytecode is interpreted). Share on Twitter Share on Facebook Pin It Hello, World! ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |