Index

37 Sensors Overview

Sensor.Engine MICRO

  1. Sensor.Engine MICRO Features
  2. Pinout and Pin use
  3. BASIC Overview
  4. SEM Library functions

37+ Sensors

  1. Analog Hall-effect
  2. Analog Joystick
  3. Analog Temperature
  4. Ball Switch
  5. Bi-color LED
  6. Button
  7. Character LCD
  8. Flame
  9. Hall-effect Switch
  10. HMI Display
  11. Humidity and Temperature
  12. IR Receiver
  13. IR Transmitter
  14. Keypad
  15. LASER
  16. Light Cup
  17. Liquid
  18. Mercury Switch
  19. Microphone
  20. Multicolor Flashing LED
  21. Obstacle Avoidance
  22. Photo Interruptor
  23. Photoresistor
  24. Piezo Driver or Annunciator
  25. Pulse
  26. Reed Switch
  27. Relays and Drivers
  28. RGB LED
  29. Rotary Encoder
  30. Servo
  31. Shock and Impulse
  32. Speaker
  33. Temperature 18B20
  34. Temperature Threshold
  35. Touch Sensor
  36. Tracking
  37. Ultrasonic Distance

USBmicro U4xx

  1. U401
  2. U421
  3. U451

CircuitGizmos

Projects

  1. Controlling MedeaWiz Sprite

SEM

Library functions



The Sensor.Engine MICRO library (installed in library flash) adds language elements to the BASIC language specific to the SEM.

SEM Startup
mm.startup is a function located in the library that will run before the main BASIC program runs in flash. For the SEM, mm.startup provides these functions:
1) Initialize the SEM LCD display.
2) Set up the SD card for access.
3) Print the banner text to the SEM display and to the serial console.
4) Get the Real Time Clock date and time, if the module is present.
5) Run AUTORUN.BAS from the root of the SD card, if the SD card and file exist.
6) Run SEM.BAS from the root of the SD card, if the SD card and file exist (and AUTORUN.BAS does not).

SEM Display initialization
sem.initdisplay reinitializes the SEM display. If the display becomes corrupt or unresponsive in use then this SEM library routine will reset and clear the display.

Display driver
The library contains the driver needed to put text and graphics on the SEM's SSD1306 display.

SD card routines
The library contains the driver needed to read/write the SD card. This is a limited version of SD card capability requiring that the SD card contain placeholder/blank files of appropriate size prior to the SEM writing to the files. There is no "create" or "delete" of files or directories from the SEM.

Load BASIC program from sd card
load(filename$) will load a BASIC program from the SD card. loadrun(filename$) will load a BASIC program from the SD card and immediately run it. filename$ is the name of the basic file. Examples:

load("FRED.BAS") loads FRED.BAS from root directory

load("APPS/WILMA.BAS") loads WILMA.BAS from the APPS subdirectory

Save BASIC program to card
save(filename$) will save a BASIC program to the SD card.

Open a file on the SD card
openfile(filename$) will setup the SEM to read from or write to a specific file. When an open is issued, the file position is reset - the first byte read using the openfile subroutine is the first byte of the file on the SD card.

Read from a file on the SD card
readfile(s$, numbytes, offset) The operation of readfile applies to the file name opened by openfile. The string s$ will contain the bytes read from the file. The number of bytes to read is set by the integer numbytes (or 1, if the field is left blank). Initially after opening the file, the data read comes from the beginning of the file. Subsequent reads come from the next unread location. offset is used to advance a number of bytes after the current location.

readfile needs to be set to an integer for the return value. In other words, the function should be assigned to an integer value when called in BASIC: n = readfile(s$) the integer n then contains the number of bytes that were read from the file.

Write to a file on the SD card
writefile(s$, numbytes, offset) The operation of writefile applies to the file name opened by openfile. The string s$ should contain the bytes intended to be written to the file. The number of bytes to write is set by the integer numbytes (or 1, if the field is left blank). Initially after opening the file, the data written goes to the beginning of the file. Subsequent writes go to the next unwritten location. offset is used to advance a number of bytes after the current location.

writefile needs to be set to an integer for the return value. In other words, the function should be assigned to an integer value when called in BASIC: n = writefile(s$) the integer n then contains the number of bytes that were written to the file.

Get the directory of the SD card
DIR(dirname$)

All content, not otherwise posted with a copyright notice, is Copyright 2017+ to the owner of 37sensors.com.