logo-mobile

ROHM

ROHM
Menu
  • Arduino –
  • Raspberry Pi –
  • Trending –
  • Others –
  • About –
  • Contact –

Raspberry Pi

The Sense HAT Add-On Board For Raspberry Pi – Sense HAT Emulator

Device Plus Editorial Team
Published by Device Plus Editorial Team at July 19, 2017
Categories
  • Raspberry Pi
Tags
  • raspberry pi
  • sense hat
  • sense hat emulator
sense hat emulator
  • Intro & Sense HAT Emulator Browser Version
  • Sense HAT Emulator Desktop Version
  • Source Code for Desktop Sense HAT emulator

 

The source code for Desktop Sense HAT emulator

In order to actually run this program on Sense HAT itself, it’s necessary to modify some source code.

Desktop Sense HAT emulator

Write your code in IDLE as before; there are also a number of examples that can be opened from the emulator’s built-in menu. If you then want to port your code to a physical Sense HAT, you just need to change

sense_emu

to

sense_hat

at the top of your program. Reverse this if you’re porting a physical Sense HAT program to the emulator, perhaps from one of our educational resources; this step isn’t required in the web version of the emulator.

Basically, it’s necessary to change “sense_emu” to “sense_hat“.

With this in mind, let’s take a closer look at the previous program.

 

Code-Example

1
2
3
4
5
6
7
8
9
10
11
12
from sense_emu import SenseHat
sense = SenseHat()
green = (0, 255, 0)
white = (255, 255, 255)
while True:
    humidity = sense.humidity
    humidity_value = 64 * humidity / 100
    pixels = [green if i < humidity_value else white for i in range(64)]
    sense.set_pixels(pixels)

There is “sense_emu” in the calling part of the program (line 1). When moving Sense HAT main unit, the browser version uses “sense_hat”, and the desktop version uses “sense_emu”. Because the desktop emulator runs the program using IDLE, you need to  choose whether to move the Sense HAT itself or start the emulator.

A web-based emulator with an editor is a perfect tool for those who want to get started using Sense HAT immediately. It’s quite for checking and practicing programming. In addition, the biggest advantage of the browser emulator is that you can still test and play without the physical Raspberry Pi device. If you are connected to an Internet with a web browser, you can play with Sense HAT anywhere, anytime!

For those with actual Raspberry Pi device, desktop emulator with more features is recommended. You can easily test your programs using the desktop emulator by changing the source code (i.e. sense_emu to sense_hat).

1 2 3
Device Plus Editorial Team
Device Plus Editorial Team
Device Plus is for everyone who loves electronics and mechatronics.

Check us out on Social Media

  • Facebook
  • Twitter

Recommended Posts

  • The Sense HAT Add-On Board For Raspberry Pi – JoystickThe Sense HAT Add-On Board For Raspberry Pi – Joystick
  • The Sense HAT Add-On Board For Raspberry Pi – Operating The LED DisplayThe Sense HAT Add-On Board For Raspberry Pi – Operating The LED Display
  • Raspberry Pi WebIOPi IOT Part 2 – Making a flashing LED buttonRaspberry Pi WebIOPi IOT Part 2 – Making a flashing LED button
  • The Sense HAT Add-On Board For Raspberry Pi – 6 Types of SensorsThe Sense HAT Add-On Board For Raspberry Pi – 6 Types of Sensors
  • DIY Raspberry Pi Drone Part 3 – FPV Setup GuideDIY Raspberry Pi Drone Part 3 – FPV Setup Guide
  • DIY Raspberry Pi Drone Part 2 – Naza-M Lite GuideDIY Raspberry Pi Drone Part 2 – Naza-M Lite Guide
Receive update on new postsPrivacy Policy

Recommended Tutorials

  • How to integrate an RFID module with Raspberry Pi How to integrate an RFID module with Raspberry Pi
  • How to Use the NRF24l01+ Module with Arduino How to Use the NRF24l01+ Module with Arduino
  • How to Run Arduino Sketches on Raspberry Pi How to Run Arduino Sketches on Raspberry Pi
  • Setting Up Raspberry Pi as a Home Media Server Setting Up Raspberry Pi as a Home Media Server

Recommended Trends

  • SewBot Is Revolutionizing the Clothing Manufacturing Industry SewBot Is Revolutionizing the Clothing Manufacturing Industry
  • All About The Sumo Robot Competition And Technology All About The Sumo Robot Competition And Technology
  • 5 Interesting Tips to Calculating the Forward Kinematics of a Robot 5 Interesting Tips to Calculating the Forward Kinematics of a Robot
  • Go Inside the Drones That Are Changing Food Delivery Go Inside the Drones That Are Changing Food Delivery
Menu
  • Arduino –
    Arduino Beginner’s Guide
  • Raspberry Pi –
    Raspberry Pi Beginner's Guide
  • Trending –
    Updates on New Technologies
  • Others –
    Interviews / Events / Others

Check us out on Social Media

  • Facebook
  • Twitter
  • About
  • Company
  • Privacy Policy
  • Terms of Service
  • Contact
  • Japanese
  • 简体中文
  • 繁體中文
Don’t Forget to Follow Us!
© Copyright 2016-2023. Device Plus - Powered by ROHM
© 2023 Device Plus. All Rights Reserved. Muffin group

istanbul escort istanbul escort istanbul escort