Look in your kitchen. A microwave oven with a glowing LED display and a rubber keyboard? It hides your brain. It’s more than just a circuit board. It is a microcontroller. These little Silicon chips are everywhere. They are buried deep within modern products. You probably use it dozens of times a day.
Think about your car. Everyone has at least one. The higher-end model can accommodate 6 to 7 cars. Only one engine works. Use different anti-lock brakes. Cruise control? This is the third one. You’ll start to see a pattern. The device you’re talking to probably has one.
They are shown on TV. They are on the VCR. Even older high-end stereo systems rely on these. Want to take a photo? In a high-quality DSLR or digital camera, it is. mobile phone? Really. camera. Answering machine. laser printer. Is it a modern phone with caller ID and a memory slot for 20 numbers? Yes. pager. Yes. They are also used in feature-rich home appliances such as refrigerators and dishwashers with digital interfaces.
Basically, when a product interacts with a user, it has a Microcontroller inside it.
But what exactly is it? Why should we care?
Understanding this component will change the way you look at technology. This is not magic. This is just engineering. Understanding how it works opens the black box. You can start building something yourself.
Let’s solve this mystery. Learn what a Microcontroller is. Understand how your data is processed. Then you have to do it. Make a digital clock. That’s it. Use a microcontroller.
Next, we will make a digital thermometer.
These items are more than just toys. They will tell you about commercially available products. See how engineers design the equipment they use. This is practical information.
“Basically, Microcontrollers are Embedded in products and devices that users interact with.”
This is the first step. All that remains is the implementation.
A microcontroller is a computer. It has the same basic structure as the desktop computer you’re probably reading this on. There is a processor that executes the code. It pulls that code from storage. It uses RAM for temporary variables. It has inputs and outputs that interact with the world.
The difference is the purpose. A desktop machine is a general-purpose machine. Run a browser, game or word processor. Microcontrollers are special machines. It does one thing. And it is very well done.
A device uses an embedded driver if it meets certain standards.
The Embedded Purpose
These chips are hidden inside other devices. They control the functionality or behavior of consumer products. You don’t see them. You only interact with the content they enable.
They are dedicated. They run a single specific program. Programs are usually stored in ROM (read-only memory) and rarely change. It’s baked in.
Power is important here. A desktop computer connected to the wall can consume 50 watts of power. A battery-powered microcontroller can consume 50 milliwatts of power. This makes a big difference in efficiency.
Inputs, Outputs, and Environment
Microcontrollers have their own input devices. They often sport a small LED or LCD for output. But most of the time they communicate with the hardware they control.
Think about a TV. The microcontroller receives input from the remote control. It displays output on the screen. Controls the channel selector. Adjust the speakers. Adjusts the tone and brightness of the cathode ray tube electronics.
Or look at your car. The engine controller receives input from the oxygen sensor and the knock sensor. Control the fuel mixture. It times the spark plugs.
The microwave oven is also a classic example. It takes input from a keypad. Shows the time on the LCD screen. It triggers a relay to turn the magnetron on or off.
These chips also face harsh environments. They are usually durable, although not necessarily strong and durable. Engine controllers for Alaskan cars must withstand temperatures down to -30°F. In Nevada, it might hit 120°F. Combined with the engine’s own heat, the car’s interior temperature can rise between 150°F and 180°F.
A microcontroller inside a VCR? It probably doesn’t care. It’s not sturdy at all.
Internal hardware
The processor itself is different. It may be ancient. It can be surprisingly powerful.
Z-80 processors can be used in digital phones. It was an 8-bit chip from the 1970s. It originally powered home computers.
Garmin GPS uses a low-power version of the Intel 80386. The 80386 is a desktop standard. Now it’s inside a portable navigator.
For simple tasks, manufacturers prefer special microcontroller chips. Price and size are the deciding factors. Motorola 6811 and Intel 8051 are historical examples. They are designed to be inexpensive, compact and low-power.
Then there are the PIC microcontrollers. There is a reason why these products developed by Microchip are so popular. By today’s standards, they are minimalist. But buy them in volume, and they are incredibly cheap. Meet the designer’s needs with one chip.
Why simplicity wins
Consider a typical low-end microcontroller chip. It can have 1000 bytes of ROM. 20 bytes of RAM. 8 I/O pins.
When produced in large quantities, the price is only a few pennies.
You will never run Microsoft Word on this. Word requires 30MB of RAM and a processor capable of processing millions of commands per second.
However, you don’t need Word to control your microwave. You need a specific task done. Low costs. Low power. This is the value proposition of microcontrollers.
Using the microcontroller
The trend is shifting. As devices become smarter, the line between “microcontroller” and “processor” becomes blurred. But the core philosophy remains. If all you need is to control relays, monitor sensors and blink LEDs, you don’t need a supercomputer. You need a focused and efficient brain.
The next time you check the clock, adjust the thermostat or start the car, remember this small, durable and inexpensive chip that works silently in the background. It’s not just hardware. It’s a specialized computer doing its job.
The best way is to build out of 7400-series TTL gates to build a digital clock. Learn how voltage spikes across a transistor. You can see why a single NOT gate is a physical chip. You can also see that implementing something complex requires complex wiring and multiple chips. A simple clock may require 15 or 20 individual components. it works. It’s bulky though. And it’s hard.
The software changes the equation completely.
Microcontrollers pack the logic of dozens of gates onto a single silicon chip. you write the program. The chip executes it. The hardware does the rest. In this article, we skip the breadboard maze and go straight to the code. We are building a digital clock. It costs almost two hundred dollars. This seems crazy for a watch that only tells the time. However, the goal is not to save money. The goal is to learn how to communicate with the microcontroller. If you understand this, you can do anything.
BASIC stamp: Hardware simplification
Most microcontrollers require assembly language or complex drivers. Requires a programmer. You need to understand clock cycles and memory mapping. Parallax’s BASIC Stamp removes this friction. This is a PIC microcontroller packaged in the BASIC language that most hobbyists know.
The name is literal. The board is about the size of a postage stamp.
We are working on BASIC Stamp Revision D. It’s not just chips. It is a fully assembled carrier board. Includes 9 volt battery holder. Equipped with a power regulator that keeps the voltage stable. Includes header pins for input/output lines. There is also a small prototyping area if you want to solder a resistor or two directly to the board. You can also buy the original BS-1 chip and wire it yourself. The Revision D just saves you the headache.
Why use “expensive” stamps?
BASIC stamps are not available for consumer products. Manufacturers hate them. they are very slow. It’s expensive. If you were to produce 10,000 units, you would probably use a standard PIC or AVR. But for prototyping? They are unbeatable.
Installing a normal microcontroller can take several hours. You need to configure fuses. You need to burn a bootloader. You need to debug serial output. The stamp only requires two things. Plug this into a port on your desktop computer. you write the program. Press send. The chip works.
With this simplicity comes a trade-off. The BS-1 memory in the stamp is limited. The EEPROM memory only holds about 256 bytes. This equates to about 75 lines of BASIC code. There are limitations. You cannot create a web server. High-resolution images cannot be saved. However, you can make the LED light blink. the sensor can be read. You can run a clock.
Build a clock
I am using this hardware to build a digital clock. It will be expensive. The board itself costs a fraction of that, but you need a computer to program it. You have to know your limits.
The 75-line limit forces you to be efficient. You cannot bloat your code. You have to consider what the chip actually needs to do. Does it need to display seconds? Yes. Does the display have to be refreshed every millisecond? Probably not. Every line is important.
This approach teaches you the core of embedded systems. It’s not just about writing code. You control your resources. You are working within hardware limits. If you can make a clock work on a Stamp, you can drive almost anything with a microcontroller. The logic remains the same. The scale changes.
The clock itself is simple. But getting there is the real value. Learn to connect using pins. Learn to manage time. Learn how to push code onto a chip with little or no memory.
“The stamps are so small and battery operated that you can take them almost anywhere.”
This portability is a real selling point. You can take the clock anywhere. You can connect sensors. You can turn it into a weather station. The base is solid. The code is tight. The equipment is minimal.
You are not just building a clock. You are building skills.
A simplified language for embedded logic
Writing a BASIC stamp is not reinventing the wheel. Uses a refined version of the BASIC programming language. If you already know BASIC, it will feel familiar, only the syntax is more precise. If you have a C, Pascal, or Java background, Stamp BASIC’s features are easy to master. If you’ve never written code, don’t start here. Please study on your desktop first.
Parallax describes this environment in detail, but for a quick overview, let’s look at a specific set of instructions designed for limited hardware.
Standard control flow and subroutines
The core logic remains constant. Here are some usual suspects for managing program flow.
for...nextfor standard cycle.gosubjumps to a subroutine.gotojumps to the marked line in the code.if...thenfor conditional decisions.letfor the task (though usually optional in Stamp BASIC).returnends the subroutine.endstops the program and puts the chip to sleep.
Direct I/O pin operations
This is where stamps live and die. Pins are interfaces to the physical world. BS-1 has 8 pins (0-7). BS-2 doubles it to 16 (0-15). They go both ways. You can read from them and write to them.
You can control them using certain commands.
buttonuses built-in debounce and auto-repeat logic to read inputs.highandlowset the pin to 1 (+5 V) or 0 (ground).inputandoutputdefine the direction of the pin.- Connect the potentiometer to the capacitor according to the instructions, and the
potwill read the potentiometer. pulsinandpulsouthandle the pulse duration input and output.pwmproduces pulse width modulation for motors or dimming.reversereverses the I/O direction.serinandserouthandle serial communication.soundproduces a specific frequency.- Change the bit status of the
toggleoutput pin.
Stamp-Specific Functions and EEPROM
The hardware has some quirks that the language directly responds to:
branchRead the branch table to speed up searches.- Sends the string
debugto the desktop console. eepromhandles program storage.lookdownandlookupallow table indexing.napandpauseintroduce delays.randomgenerates pseudo-random numbers.readandwriteuse non-volatile EEPROM memory.sleepturns off the chip for a certain time.
Arithmetic and logical operators
Mathematics is fundamental. It’s very basic.
+and-for addition and subtraction.*for low word multiplication.**for high-word multiplication.
●/for division.- for modulo.
maxandminare used to find extreme values.
Logical operations are e.g.
&(and)|(or)
–^(XNOR)
–&/(NAND)|/(NOR)
–^/(XNOR)
Comparison operators for the if statement are =, <>, <, <=, >, >=, AND, OR.
Memory limit: 14-Byte Reality
BS-1 variables are not infinite. There are exactly 14 bytes of RAM. You have to treat every byte like gold.
The language provides predefined variable names, but you can also add aliases to variable names.
w0-w6: 16-bit word variables.b0-b13: 8-bit byte variables.bit0-bit15: 1-bit Boolean variables.
This is the problem. Due to the way memory is mapped, the w0 and b0 (and b1 ) share the same physical RAM location. w1 is shared with b2 and b3. bit0 –bit15 are in w0. This means that changing w0 will also change b0 and b1. This is not an error. This is a limitation. You need to know exactly what you are overwriting.
Speak to the world through pins
Why are there so many I/O instructions? Because these pins are the only way the stamp communicates with the outside world.
Sending values is easy. high 3 transmits +5V on pin 3. low 3 sends ground. You can choose any pin from 0 to 7 of BS-1. The logic is similar to BS-2, but there are more pins to control.
Advanced instructions such as pwm for motors and pot for variable resistors simplify hardware design. No complex external circuitry is required for each analog input. The stamp handles the timing of the pulse.
If you're stuck, "Programming and Customizing a BASIC Stamp Computer" by Scott Edward is a reliable resource. It includes an example project that shows how to connect these things together instead of just writing code.
You don't need a PhD in embedded systems to start using BASIC Stamp. All you need is a desktop computer and the BASIC Stamp Starter Kit. This kit includes the necessary hardware, connection cables, and a desktop application to push the BASIC code into the chip's memory.
This package can be purchased from Parallax or Jameco, suppliers you may know from our previous articles on electronic gates and digital clocks. Parallax lists the BASIC Stamp D Starter Kit as part number 27202. Jameco's part number is 140089. Both are $79.
Parallax occasionally runs "We've Bagged the Basics" campaigns. This deal adds Scott Edward's "Programming and Customizing the BASIC Stamp Computer" to your box. This is a useful reference if you want to dig deeper than the manual.
Wiring and code execution
The physical setup is easy. Connect the stamp to the parallel port of your computer. Then run the DOS application, edit the code, and send it down the wire.
Press ALT-R to run the program in the editor. The software checks your syntax first. Then push the code into the stamp's EEPROM memory. The chip executes it immediately.
The default example creates a square wave on I/O pin 3. Connect a logic probe or LED to this pin. You will see it flash twice per second. The PAUSE command causes the state to change every 250 milliseconds.
This device draws enough power to run for several weeks on a 9-volt battery. You can squeeze out more life by tweaking the timing. Turn the LED on for only 50ms and then turn it off for 450ms. Switching from PAUSE instructions to NAP instructions can also significantly reduce power consumption.
Creating a Really Expensive digital clock
Spending $79 on flashing lights seems like a waste. Most people want to build something useful with BASIC Stamp. Another $100 gets you a digital clock. The cost seems high until you realize that the parts are not disposable. They are reusable. We will use these in future projects.
Drive multiple numbers with limited Pins
Suppose you need to display a number on an I/O pin. In our previous digital clock guide, we showed how to use a 7447 chip to connect to a 7-segment LED. These chips work well with the BASIC Stamp. Connect 4 pins directly to 7447. A number between 0 and 9 appears on the display. The BS-1 stamp has eight I/O pins. This is enough to power two 7447s directly.
The clock requires 4 digits. Eight pins cannot drive four chips at the same time. you get creative.

Here is the setup. Eight lines come from the Stamp. Four lines are connected to all four 7447s. They carry data. The other four lines activate the chips one by one. The 7447's "E" pin is an enable input. It blanks the display. The stamp program outputs the first digit. Switch the first control line to enable the first chip. Then send another value. It enables the second chip. Repeat all four over and over again.
You can connect in many different ways. 7447 might be enough. Use a 74154 demultiplexer. More drivers. This way you can drive up to 16 digits.
The reality of multiplexing
This is how you control your LED display. Open the old LED calculator. Turn it on. Shake while looking at the screen. Pay careful attention. Only one digit is lit at a time. This technique is called multiplexing the display. Trick your eye into seeing the complete number.
Multiplexing works with clocks. Works with a calculator. It has problems.
LEDs drain power. Quickly.
7 segment LED displays only numbers.
Quantities are limited. What about letters? What about the symbols?
Switch to LCD
An LCD screen is the alternative. These screens are everywhere. They are easy to hook up to a Stamp.
Consider a two-line, 16-character alphanumeric display. This type is available from Jameco. Part number 150990. Also available at Parallax. Part number 27910.

This image shows a typical display. It is attached to a breadboard. This makes interfacing easier. You don't solder wires to exposed parts. You are plugging into rows.
Single-line LCD is expensive, but for a simple reason
You get what you pay for. This type of LCD module is expensive. The price is around $59. That is not exactly pocket change for a hobbyist. It certainly cannot be used in mass-produced ovens. The margin would vanish before you sold the first unit.
But they exist for a reason. The design process is simplified. You can drive the entire display using just one I/O pin.
This module contains logic. It handles the heavy lifting of serial communication. The Stamp microcontroller only needs to send data. The SEROUT command in Stamp BASIC makes this trivial. No complex timed loops required. You do not need to wrestle with protocol specifications. The hardware does the work.
Power and display functions
Power consumption is very low. This device consumes only 3 milliamps of current. That is negligible for a battery-powered project. It is powered by a standard 9 volt battery via a stamp that provides the necessary +5 volts and ground.
The screen itself is versatile. It shows alphanumeric text. Letters. Numbers. You can also define custom characters if you want a specific icon. It's more than just a flashing light. It is actual text output.
Prototype and production
This is the reality of embedded design. You can create prototypes with expensive but easy-to-use parts. Then you redesign for cost.
If you're building a commercial product, you'll use this $59 display to validate your logic. Test your code. You would ensure the interface works. Once that's confirmed, I'll move on to a cheaper general-purpose LCD. You would write custom driver chips. Optimize your software. Expensive modules are development tools, not final delivery tools.
Make a connection
Connecting the hardware is very easy. Supply +5V and ground. Connect one of the label's I/O pins to the input line of the monitor.
I prefer wire wrapping for this. It is clean. Reliable. It requires no soldering. You need a wire-wrap tool (Jameco part 34577) and 30-gauge wire wrap wire (Jameco part 22541 is a common choice). The connection structure is compact. You can put everything in a small case without tons of soldering iron.
Code structure and accuracy
The BASIC program below turns the Stamp into a clock. It assumes the LCD is connected to I/O pin 0.
""Basic
pause 1000 ' Wait for the LCD to boot up
serout 0, n2400, (254, 1) 'Clear the screen
serout 0, n2400, ("time:") 'Print the title "time:"
' Preset variables before loading the program
b0 = 0 ' Seconds
b1 = 27 ' Minutes
b2 = 6 ' Hours
again:
b0 = b0 + 1 ' Increment seconds
if b0 < 60 then minutes
b0 = 0 'reset seconds
b1 = b1 + 1 ' addition
Minutes:
time if b1 < 60
b1 = 0 'Reset the minutes
b2 = b2 + 1 ' Add time
Time:
Show if b2 < 13
b2 = 1 'Reset time (12 hour format)
Display:
serout 0, n2400, (254, 135) ' cursor position
serout 0, n2400, (#b2, ":", #b1, ":", #b0, " ") ' Display time
pause 950 ' wait 950 ms
Proceed to "Play" again.
""
The logic is simple. The SEROUT command handles all communication. The series (254, 1) serves as an escape code. Tells the monitor to clear the screen. The set (254, 135) positions the cursor. All you need to do is send a text string.
The watch is quite accurate. You can modify the PAUSE statement by adjusting it. It can be completed in seconds every day. It is not as accurate as an atomic clock. However, this is enough for standalone devices.
This approach
Simple timing loops can drift. If you need precision, you need hardware.
Real Time Clock (RTC) chips solve the drift problem. A crystal is used to maintain the accuracy of the time. Attach it to the stamp. The Stamp reads approximately once per second. Next, display the information.
It's not just a matter of seconds.
Most RTC chips also handle date information. Leap year corrections are managed automatically. Your code does not need to calculate whether there are 28 or 29 days in February. That's the role of the chip.
Use pocket watch B
Combining RTC and stamps can be complicated. Data and clock lines require multiple pins. There is an easier way.
Use pocket watch B.
This module simplifies connectivity. Use a serial connection. Only one I/O pin is required for communication. This frees up pins for other sensors and displays.
The equipment is compact. It is about the size of a quarter. Internally, the clock chip, crystal and serial logic are integrated into one package.
Where did you buy it?
Two major suppliers stock this part. Jameco's part number is 145630. Parallax sells it with part number 27962.
Price is also a factor. Pocket watch B sells for about $30. That is steep for a hobbyist toaster controller. You wouldn't embed that in a consumer appliance. But for prototyping? Cheap enough to try.
Eliminate the hassle of manually managing I2C or SPI protocols. Write less code. You will get a more precise time.
Make a digital thermometer
We already know how the stamp communicates with the LCD. So let's give it a way to perceive the world. More specifically, I'm building a digital thermometer. At the core of the project is a specialized temperature sensor chip, the DS1620.
This is not just a resistor whose resistance changes with heat. The DS1620 is a complete system in one 8-pin package. It contains a temperature sensing device, an analog-to-digital (A/D) converter and a shift register to process the data output. It also contains a small section of EEPROM for storing settings such as thermostat mode.
Understand the operating modes of the DS1620
Chips are flexible. It acts as a separate thermostat and triggers a relay when the temperature exceeds the threshold. Alternatively, it can be connected to a microcontroller and used purely as a precision thermometer. The EEPROM remembers the selected mode and settings.
Connecting to BASIC stamps is also easy. No complex circuits required. Follow the stack specifications.
- Pin 8: +5 volt power supply.
- Pin 4: Ground.
- Pin 1 (Data): Data line. Bits go in and out of here.
- Pin 2 (clock): Clock line. This synchronizes the data transfer.
- Pin 3 (Reset/Select): Control line. Communicate with the chip as you level up. Low to deselect.
In this example, we connect them to specific I/O pins on the stamp.
- Data (pin 1) is connected to Stamp Pin 2.
- Clock (pin 2) is connected to stamp pin 1.
- Reset (pin 3) is connected to Stamp pin 0.
It is worth paying to get the Jameco or Parallax application package. This document takes the guesswork out of configuration.
This can be built on a Stamp Vector prototyping area or on a breadboard. After connecting the DS1620, connect the LCD to I/O pin 3. Then download the following BASIC code.
""Basic
Select/reset row with symbol RST = 0 ' 1620
Symbol CLK = 1 ' 1620 shift register clock line
2' data line with symbol DQ = 1620
Symbol DQ_PIN = pin2 ' Pin representation of DQ
Symbol LCD = 3' LCD data line
Get started:
Low RST "Remove 1620 unless spoken to"
HIGH CLK' 1620's clock pins are set to HIGH by default.
pause 1000 and wait for the thermometer and LCD to turn on
Settings:
HiRST'Select 1620
b0 = $0C ' $0c is 1620 command bytes ' means 'Write configuration'
Send to gosubshift_out '1620
b0 = %10 ' %10 is 1620 command bytes ' Set thermometer mode
Send to gosubshift_out '1620
Uncheck "Low RST" 1620
Pause 50' is an EEPROM delay of 50 ms
Start the conversion:
b0 = $EE ' $EE is 1620 command bytes ' Start conversion
HiRST'Select 1620
Send to gosubshift_out '1620
Uncheck "Low RST" 1620
"This is the main loop" - reads and displays the temperature every second
Main loop:
HiRST'Select 1620
b0 = $AA ' $AA is 1620 command bytes used to read the temperature
Send to gosubshift_out '1620
gosub SHIFT_IN 'Reading temperature from 1620'
"Low RST" deselects the DS1620.
gosub display 'Display the temperature in degrees Celsius
Pause 1000 'Wait a minute
goto main_loop
'shift_out subroutine' sends the contents of the b0 byte to 1620
Go out:
Output DQ ' Set the DQ pin to output
for b2 = 1 to 8
low CLK
DQ_PIN = bit0 'Send data bit
high CLK
b0 = b0/2
Next
Back
'shift_in subroutine gets 9 bits 1620' of temp
Move in:
input DQ 'Set DQ pin to input mode'
w0 = 0 ' Clear w0
for b5 = 1 to 9
w0 = w0/2 ' Shift the input to the right.
low CLK
bit8 = DQ_PIN 'Read this bit
high CLK
Next
Back
'Display temperature in degrees Celsius
Display:
if bit8 = 0 then pos 'if bit8=1' then temp is negative
b0 = b0 &/ b0 ' NAND b0 with itself and flip it '
b0 = b0 + 1
Position:
Serial LCD, n2400, (254, 1) 'Blank LCD
serout LCD, n2400, ("Temp = ") ' Display "Temp="' on the screen
bit9 = bit0 'Save half a degree
b0 = b0 / 2 ' converts to degrees
if bit8 = 1 then neg ' Check if temp is a negative number
serout LCD, n2400, (#b0) 'Display positive temperature
goto half
Negativity:
serout LCD, n2400, ("-", #b0) 'Display negative temperature
half:
If bit 9 = 0, even number
serout LCD, n2400, (.5 C") 'display half degree
goto done
Even number:
serout LCD, n2400, (.0 C") 'Display half degree
done:
Back
""
Run this program. The LCD display shows the temperature in degrees Celsius with an accuracy of 0.5 degrees.
How 2's complement works in DS1620
The DS1620 does not send simple numbers. Measured 0.5 degrees Celsius. Prints a 9-bit two's complement binary number.
Why is this important? Correct handling of negative temperatures. The range is -55°C to +125°C (-110°F to +250°F). Divide this value by two to get the measurement in degrees Celsius.
Two's complement is the standard way computers represent signed integers. The leftmost bit is the sign bit. If 0, the number is positive. If 1, the number is negative.
Let's look at a 4-bit example. These values are -8 to +7 instead of 0 to 15.
0111is 70000is 01000is -81111is -1
To convert a negative number to a positive number and display it, flip all the bits and add 1. This code does just that in the display subroutine. Check bit8 (sign bit of 9-bit result). If negative, invert b0 and add 1. Then shift it to the right to get integer powers.
Extract the code logic
This program uses three subroutines to manage the communication protocol.
Symbol Definition
This code uses symbol to map physical PIN numbers to human readable names. RST, CLK, DQ correspond to stamp pins 0, 1, 2. This makes your code portable. Even if you change the symbol definition, the rest of the logic remains the same.
Uninstall the program
shift_out takes the bytes of b0 and sends them one bit at a time.
1. Assign data pin (DQ ) as output.
2. Spin 8 times.
3. Check the least significant bit of b0.
4. Pull the clock pin down, set the data pin to that bit and pull the clock pin up.
5. Shift b0 to the right so that the next bit moves to the least significant position.
Shift exchange procedure
shift_in reads a 9-bit temperature value into w0.
1. Configure the data pins as inputs.
2. Spin 9 times.
3. Pull the clock pin down.
4. Read data pin status to `.
The code doesn't just read data. It lays the foundation. Forces the DS1620's CLK and RST pins to the expected state. This is the first step.
Next is the configuration. The microcontroller writes the command byte to the EEPROM memory of the DS1620. Have the chip go into "thermometer mode". Here’s the catch. Patterns are stored in non-volatile memory. You only need to do it once. Technically, you can remove this part of your code after the first run, saving valuable program space. But shall we leave it at that? It's safer.
The program then sends the command $EE. Note that the "$" prefix means a hexadecimal number. The decimal value of $EE is 238. This starts the conversion process. The thermometer starts working.
Then the cycle begins.
The stamp asks the DS1620 for the current temperature every second. The chip responds with a 9-bit value. This value is in the variable w0. Data transfer happens a little at a time. The Stamp toggles the CLK line on the DS1620 to shift bits in.
The structure of the variable is hierarchical. w0 (16 bits) covers b0/b1 (8 bits) and covers bit0 to bit15 (1 bit). This code divides w0 by two when the bit appears in bit 8. This shifts each bit to the right. This is a great way to pack 9-bit temperatures into a variable.
When w0 saves the data, it is applied by the screen subroutine. Check if the number is positive or negative. It formats the output for the LCD screen. Results are displayed in degrees Celsius. If you need Fahrenheit, the conversion is easy.
dF = dC * 9/5 + 32
It's very simple. it works. You now have a very expensive thermometer.
Why pay so much?
Imagine you work for a pharmaceutical company. You deliver expensive medicines around the country. These medicines must be stored at certain temperatures. Thawing or freezing will damage it. Total loss.
You can use Stamp to build a Data Log Thermometer.
Jameco sells the RAM Pack Module (part number 143811). Parallax also sells the same product (product number 27960). This is a low power 8KB RAM chip with a serial interface. If you need more space, you can also choose the 32 KB version.
Add this component to your stamp. Write code that saves temperature readings to RAM every minute. Slip the Stamp into the drug shipment. You will receive a stamp when you arrive at your destination. The RAM module now records the temperature history of the entire trip. You’ll know exactly if the drugs ever went out of spec.
This is just one application. Once you understand how microcontrollers work, you can use Stamp to build countless useful devices.
You can find more information about microcontrollers and related topics from the links on the following pages:
The specs got thicker. This is not a manual you can read once and then forget. Thicker in the sense that there were the actual numbers. These numbers tell you exactly what the machine could do before you buy it. And there are even more numbers. Next is the battery life disclaimer. that was technically true, it is but practically useless.
Hardware reality check
You get the processor. It's fast. It's faster than the last one. It's faster than the old laptops that sounded like a jet engine taking off every time you open a spreadsheet. But it's not magic. This chip does not clean the room. It just processes data. Quickly. It is very fast. If you are editing a video. Or coding. Or open 50 tabs and wonder why your A computer is getting so hot?
The screen is brighter. This is the main selling point. You can look at it outside. Without squinting. Without wishing your eyes had built-in HDR. Colors are accurate. If you care about that sort of thing. If you are a designer. Or just tired of pictures that look like they were taken in a cave.
Next, the weight. It is lighter. But it's not feather-light. You still feel it in your bag. It has a strong presence. A reminder that you are carrying a A computer. It's not a tablet. It is not a notebook in the paper sense. A computer. With ports. Real ports. It's not a dongle. Not adapters that cost more than the device. This matters. A lot. Because dongles break. Adapters get lost. Ports stay.
Software quirks and updates
The operating system is the same. Mostly. But there are also changes. Small ones. Things you notice after a week? Not immediately. A new icon will appear immediately. New color scheme. When you open the app you used 10 minutes ago, there is a Small ones delay.
Updates happen automatically. This is good. And bad. Good because you don't have to think about security patches. Bad because, your machine might reboot just when you think you're done for the day. It happens at inconvenient times. Like right when you are about to save a document. Or right before a meeting.
This software package is included. It is always tied together. You have a word processor. Spreadsheet. presentation tools. they work together. They don't always work well together. But they tried. There is cloud sync. It's fast. Usually. Sometimes it stops. After that you need to restart the application. Then you must pray.
Ecosystem trap
This is the part that people ignore until it's too late. The device is not in a vacuum. Lives in the garden. Fenced garden. You can walk out. But why do we do this? These apps have been carefully selected. The mix is profound. The phone communicates with the laptop. The watch tells your phone what to do. It is very convenient.
But it is also limiting. When you change brands. This convenience has been lost. Eliminate channel switching. I lost my shared clipboard. I can't answer calls on my A computer. This seems like a Small ones thing. it is not. It's daily friction. Add a little excitement.
The rest is the price of accessories. It's not the price. Payment. Own cable. special charger. This is a perfect case. It's expensive. And they are beautiful. and


















