Code Lessons: My LED Sign
Step 0: Get the files on your computer
To change the code yourself, you need your own copy of the files.
- Click the button above. The file goes to your Downloads folder.
- Open File Explorer and find
lesson.zipin Downloads. - Right-click it and choose Extract All…, then click Extract. (Do not just double-click the zip. Files in a zip cannot be saved.)
- Open the new folder. Inside you will find:
index.html= the control pagesign.html= the LED signmenu-data.jsandMenu-Clean.csv= the menu food listLESSONS.md= these lessons as a plain text file
- Double-click
index.htmlto open it in your browser. It works with no internet! - To edit: right-click
sign.html> Open with > Notepad.
Keep all the files in the same folder. The pages look for each other, and they get lost if you move just one.
Made a big mess? Delete the folder, then download and extract lesson.zip again for a fresh start.
Try the pages right here
Want to see what you are going to change? Open the pages in your browser (they open in a new tab):
Open the control page Open the LED sign
These are the original pages. Your own copy, on your computer, is the one you change.
You have two web pages:
index.html= the control page (buttons, drop-downs, graph).sign.html= the LED sign (the glowing menu sign and remote).
How to work (do this every time!)
- Open the file in Notepad (right-click > Open with).
- Change something. Press Ctrl+S to save.
- Go to the browser. Press F5 to refresh.
- Did it work? Yay! Did not? Press Ctrl+Z in Notepad to undo, and try again.
Finding things: press Ctrl+F in Notepad and type a word to jump to it.
Tip: you cannot break anything for good. If something goes wrong, download lesson.zip again (see Step 0) for a fresh copy.
Lesson 1: Three languages, three jobs
A web page is made with three things. Think of a person:
| Language | Like a… | Job |
|---|---|---|
| HTML | Skeleton | What is ON the page (words, buttons, boxes) |
| CSS | Clothes | How it LOOKS (colors, sizes, fonts) |
| JavaScript | Brain and muscles | What it DOES (clicks, moving, thinking) |
In your files:
- HTML is between
<body>and<script>. - CSS is between
<style>and</style>(at the top). - JavaScript is between
<script>and</script>(at the bottom).
Try it
- Open
sign.html. Find<h1>LED Sign</h1>. ChangeLED SigntoMy Sign!Save, refresh. - Open
index.html. FindIndian Food. Change it to your favorite food.
What you learned: words between tags like <h1> and </h1> show on the page. The / means “stop”.
Lesson 2: Change a color (CSS)
Open sign.html. Search for --led. You will see:
--led:#2694A3;
That is the sign’s glow color. Colors can be written 2 ways:
- A name:
red,gold,blue,purple,hotpink - A code:
#then 6 letters/numbers, like#FF0000(red)
Try it
- Change
#2694A3tored. Save. Refresh. The sign is red! - Try
gold,lime,hotpink. - Now try the code
#FFDB18. Only ONE#! (##FFDB18does not work. The browser just ignores it and does not tell you.)
Color mixer: Search the web for “color picker” and copy the # code it gives you.
What you learned: CSS lines look like what: value; and end with a ;.
Lesson 3: Change the size and the font (CSS)
In sign.html, search for 3.2rem:
font:700 3.2rem "Courier New",monospace;
700= how bold the letters are.3.2rem= how big. Bigger number = bigger letters."Courier New"= the font.
Try it
- Change
3.2remto5rem. Save. Refresh. (Then try1rem.) - Change
"Courier New"toImpact, thenGeorgia, then"Comic Sans MS". - Change
700to400. What happens to the letters?
What you learned: one line of CSS can control size, boldness and font.
Lesson 4: Change what a button does (JavaScript)
Open sign.html. Search for faster. You will see:
$('faster').onclick = () => { speed = Math.max(4, speed - 2); show(); };
Read it like a sentence:
$('faster')= find the button namedfaster..onclick= when it is clicked…speed = speed - 2= make the number smaller (faster scroll).show()= draw the sign again.
Try it
- Change
speed - 2tospeed - 5. Now the button is extra strong! - Near the top of the script find
let power = true, speed = 14. Change14to4. The sign starts super fast. - Find
modes = ['scroll', 'static', 'flash']. Swap the order, like['flash', 'scroll', 'static']. What does the Mode button do now?
What you learned: a variable (like speed) is a box that holds a number or a word. Buttons change it.
Lesson 5: Use the Editor (and see how it works)
On the sign page, click Editor. A box opens with text, font, color and size.
Try it
- Type your name in the text box. It appears on the sign as you type.
- Pick a font, pick a color, slide the size.
- Click Reset. Everything goes back.
Now look at the code
Search for edColor in sign.html:
$('edColor').oninput = () => { document.documentElement.style.setProperty('--led', $('edColor').value); };
It changes the same --led color you edited in Lesson 2, but while the page is running! CSS is the paint. JavaScript is a hand painting it live.
Try it
- Add a new font. In the HTML find the line with
Arial,sans-serif. Copy the whole<option>...</option>line, paste it under itself, and change it toVerdana,sans-serifand the name toVerdana. - In
edSize, changemax="6"tomax="10"for giant letters.
Lesson 6: Send the menu from page 1 to page 2
- Open
index.htmlin the browser. - Pick a Date and a Meal from the drop-downs.
- Click send (the side panel at the bottom right).
- The sign page opens showing that meal!
How? Look at the address bar on the sign page. After the ? it says date=...&meal=.... Page 1 writes a note in the address, and page 2 reads it.
Try it
- On the sign page, use the < and > buttons to change meals.
- Find
Open the signinindex.html. Change those words toSee my sign!. - Find the banner words (
Indian Food) inindex.htmland change them.
Lesson 7: Menu data (a peek at where the food comes from)
Open Menu-Clean.csv (double-click; it opens in Excel). Each row is one food item: Date, Day, Meal, Category, Item.
The messy first file Menu-Items.csv had a grid that was hard for computers. Cleaning data means making it tidy: one fact per row.
Try it
- In
Menu-Clean.csv, find a food and change its name. Then openmenu-data.jsin Notepad, find the same food, and change it too. The sign page usesmenu-data.js! - Refresh the sign. Did your new food name show up?
Words to know
| Word | Meaning |
|---|---|
| Tag | <h1> and </h1> mark the start and end of something in HTML |
| Class / id | A name tag so CSS and JavaScript can find a thing |
| Variable | A box that holds a number or word (speed) |
| Function | A set of steps with a name (show()) |
| Bug | A mistake in code. Fixing it is debugging |