Skip to content
  • Home
  • Account
  • Restricted content
  • OBEX
  • Chips Tips
  • Logout
  • Shop
  • Blog
Propeller OBEX
  • OBEX
  • Forum
Login
Propeller OBEX

Propeller 1

  • How to pause in PASM
  • How to choose between VAR and DAT
  • WAITPEQ and WAITPNE with PASM
  • IO pin manipulation using PASM
  • Control IO pins from any cog
  • 3D Models for Parallax Products
  • Implementing Abstract Data Structures with Spin Objects
  • Making in USA - The Parallax 8 core microcontroller
  • Simultaneous pin group control
  • Programming the FLiP module over WiFi
  • Keep any value in range
  • Handy Diagnostic Heartbeat
  • Customer Code Deployment in one click

Propeller 2

  • Floating point operators in SPIN2
  • 64/96/128-Bit Unsigned Integer Math
  • 3D Models for Parallax Products
  • DEBUG Plot Layer and Crop
  • Floating point
  • Getting Started Video Tutorials
  • Using the counter for timeouts
  • asmclk and the automatic clock setter
  • Sharing variables between SPIN2 and PASM2
  • Keep any value in range
  • Determine pin state - High, Low or Floating?
View Categories
  • Home
  • Docs
  • Chips Tips
  • Propeller 1
  • Keep any value in range

Keep any value in range

Reading Time: < 1 min read

SPIN, SPIN2

Introduction #

The Propeller native SPIN and SPIN2 languages include many efficient instructions to solve common programming tasks.

For example, how to keep a value between a certain range of allowed values?

Here's an example using just one line of code!

Code Snippet #


value := 1 #> value <# 4               ' Limit value range from 1 to 4 	
				

The result of the operation follows these rules:

  • If value is less than 1, then value = 1
  • If value is greater than 4, then value = 4
  • If value is 1, 2, 3 or 4, then value will remain unchanged.

Resources #

Parallax Propeller 1 - Spin Language Documentation

Parallax Propeller 2 - Spin2 Language Documentation


Was this useful ?
Share This Article :
  • Facebook
  • X
  • LinkedIn
Still stuck? How can we help?

Still stuck? How can we help?

Updated on December 16, 2024
Programming the FLiP module over WiFiHandy Diagnostic Heartbeat
Table of Contents
  • Introduction
  • Code Snippet
  • Resources

Copyright © 2025 - Parallax Inc.
599 Menlo Drive | Rocklin, CA 95765 | USA