Your starter sketch
This is your starting point: every part on your machine is already named, and one example rule is there to change. Copy it into File, New Sketch. Then we write the rest together, one line at a time, in Ask Milo below.
// 12 Your Own Machine: the starter
// The Maker's Book of Origins, chapter 12. Upload it, then turn back to the book.
// makernest.com/origins/12
// MakerNest Origins is a brand of Innointel Global Private Limited.
#include <MakerNestOrigins.h>
// This is your sketch. Every part of the machine is already named, and everything you set
// in the other chapters can be read. Write your sentence first, in your rough notebook:
// It should ______ when ______, and I will know it worked if ______.
// Then write the code here, one line at a time. Milo is at the link above if you get stuck.
//
// The pins: PIN_SENSOR_A 2 PIN_DIAL_CLK 3 PIN_DIAL_DT 4 PIN_DIAL_SW 5
// PIN_BUZZER 6 PIN_SENSOR_B 7 PIN_DOOR 8 PIN_LAMP 9 PIN_RING 11
//
// What the machine knows: What it can do:
// machine.temperatureA() machine.ring(RED) GREEN BLUE WHITE PURPLE YELLOW ORANGE RING_OFF
// machine.temperatureB() machine.ringNormal()
// machine.humidityA() machine.buzzer(true) steady
// machine.count() machine.buzzerBeep(true) on and off
// machine.openingsInLastHour() machine.lamp(true)
// machine.runSequence()
// Your settings:
// machine.settings.coldLine .stopAt .apartBy (half degrees) .settle .tooMany .normalColour
void setup() {
machine.begin(12, "12|YOUR OWN|MACHINE");
machine.homeShows(SHOW_A | SHOW_B | SHOW_COUNT);
machine.useScreen(SCR_COLD_LINE); // add the screens you need
machine.useScreen(SCR_STOP_AT);
}
void loop() {
machine.update(); // always first
// Your code goes here. An example to change or delete:
if (machine.temperatureA() > 30) machine.ring(ORANGE);
else machine.ringNormal();
}
Your settings and your notebook stay saved on the board when you upload.
Wiring
Nothing new to wire in this chapter. Here is the whole shield, so you can check every wire.
The whole shield, by the end of the book
On the bench: Take any bench circuit and change one thing in its code
Before you change anything, say out loud what you think will happen. Then upload and find out. The surprise is where you learn something.
- Pick one bench circuit you have already built, and build it again.
- Pick one change. One. Write in your rough notebook what you think will happen.
- Change the sketch, upload it, and watch.
- Write what actually happened next to your guess. If it surprised you, ask me why.
Ideas for one change
- Bench 02: Make the LED come on above the line instead of below it.
- Bench 03: Add a third note, and make the gap between notes shorter.
- Bench 04: Make it wait five seconds before it switches off, but only half a second before it switches on.
- Bench 05: Make the LED blink when the two sides are almost equal.
- Bench 06: Make button two reset the count to zero instead of taking one away.
- Bench 08: Add a flashing green before yellow.
- Bench D: Make the night tune play only after three presses.
- Bench 10: Make it wave once in the day and three times after dark.
How the bench works
Bench sketches replace your chapter sketch while you use them. Your settings and your notebook stay saved on the board. When you finish, upload the chapter's sketch again and your machine is back exactly as it was.
While a bench sketch runs, the display and the ring freeze on whatever they last showed. That is normal.
If the light ring is still lit from your chapter sketch, switch everything off and on again before you start. It goes dark and stops using power the bench needs.
The breadboard has 17 numbered columns and two halves, top and bottom. The five holes in one column of one half are joined underneath. Nothing joins across the gap in the middle.
Every jumper from the shield has a female end: push it onto a shield pin. The male end goes into the breadboard. G, V and S are the same three pins you have used all book: ground, power, signal.
Never put a wire straight from V to G. That is a short circuit.
Ask Milo
Stuck, curious, or something looks wrong? Tell me what you see.
You can paste your code or an error message here too.