Latest / CyberSecurity Summary / Arduino Cookbook: Recipes to Begin, Expand, and Enhance Your Projects
Transcript
- 0:00Speaker 1: Welcome to the deep Dive, the place where we take
- 0:02Speaker 1: your source material and find the most valuable insights just
- 0:06Speaker 1: for you.
- 0:07Speaker 2: And today we're doing a deep dive into these excerpts
- 0:10Speaker 2: from the The Ardueno Cookbook, third Edition. You've given us
- 0:14Speaker 2: quite a collection.
- 0:14Speaker 1: Here, right, a really good stack chapters appendices, covering well
- 0:19Speaker 1: everything from the real basics like programming in math, all
- 0:22Speaker 1: the way up to networking, sensors, motors, sound displays.
- 0:27Speaker 2: And even the really nitty gritty stuff like low level
- 0:30Speaker 2: hardware details and memory optimization.
- 0:33Speaker 1: It's packed, it really is. Think of this deep dive
- 0:36Speaker 1: as your guide, helping you navigate the practical side of
- 0:39Speaker 1: making things with Arduino. We're pulling out the key ideas,
- 0:42Speaker 1: the surprising details from these sources to get you informed fast.
- 0:45Speaker 2: Yeah, the goal seems to be moving beyond just blinking
- 0:48Speaker 2: an led Right, how do you build something interactive, something connected,
- 0:51Speaker 2: something smarter?
- 0:53Speaker 1: Exactly? So we'll explore the programming building blocks, how your
- 0:56Speaker 1: board talks to things, how you sense the world and
- 0:58Speaker 1: make things happen in it, connect online, manage time, and.
- 1:01Speaker 2: Even peek under the hood at the hardware and how
- 1:03Speaker 2: to make your code run efficiently.
- 1:05Speaker 1: Okay, let's unpack this stack. Where do we start foundation?
- 1:09Speaker 1: I guess programming basics.
- 1:11Speaker 2: It makes sense Chapter two parts of the preface ye,
- 1:14Speaker 2: chapter one. Yeah, they all lay this groundwork. And yeah,
- 1:18Speaker 2: it confirms our dueno programming is based on C and
- 1:21Speaker 2: C plus plus nine.
- 1:22Speaker 1: It feels very practical, not theoretical totally.
- 1:25Speaker 2: The focus is immediately on what you need to do,
- 1:28Speaker 2: like that basic sketch structure you always see set.
- 1:31Speaker 1: Up which runs just once right when you power up
- 1:33Speaker 1: a resea.
- 1:34Speaker 2: Exactly, and then loop which just well, loops runs over
- 1:37Speaker 2: and over.
- 1:38Speaker 1: And the sources also mention serial event.
- 1:41Speaker 2: Ah. Yes, that's a handy one. It's a special function
- 1:44Speaker 2: that runs automatically if there's new serial data waiting. Good
- 1:47Speaker 2: for handling incoming messages without constantly checking in your main loop.
- 1:51Speaker 1: But not on all boards you mentioned.
- 1:53Speaker 2: Right, important caveat boards like the Leonardo anything based on
- 1:56Speaker 2: the Ateen Mega three to two AT four, they don't
- 1:58Speaker 2: support serial event in the same way you'd handle cereal
- 2:01Speaker 2: differently there.
- 2:01Speaker 1: Okay, so inside setup and loop you're dealing with data.
- 2:06Speaker 1: The sources introduce data types like INNT and there's a
- 2:10Speaker 1: catch there.
- 2:11Speaker 2: Yeah, this is a good detail. They highlight and int
- 2:13Speaker 2: isn't always the same size. On an HUNO an eight
- 2:16Speaker 2: bit board it's two bytes okay, But on a thirty
- 2:18Speaker 2: two bit board like a SAMD based one, and int
- 2:21Speaker 2: is usually four bytes ah okay.
- 2:23Speaker 1: That could definitely cause problems if you're not expecting it,
- 2:25Speaker 1: especially sending data between different board types.
- 2:28Speaker 2: Precisely, they point out that unsigned short inint is reliably
- 2:32Speaker 2: two bytes on both, which can be useful if you
- 2:34Speaker 2: need a consistent size.
- 2:36Speaker 1: Good tip and for collections of data arrays. The sources
- 2:40Speaker 1: seem pretty insistent about checking array bounds.
- 2:42Speaker 2: Oh, absolutely critical. It's so easy to write code that
- 2:45Speaker 2: accidentally reads or writes past the end of your array.
- 2:48Speaker 1: And the compiler one always warn you.
- 2:50Speaker 2: Often it won't know, and then your sketch just crashes later,
- 2:53Speaker 2: maybe seemingly randomly. It's super frustrating. Using a constant for
- 2:57Speaker 2: the eray size and checking against it is key makes sense.
- 3:00Speaker 1: Then there's text. The book compares our dueno string objects
- 3:03Speaker 1: with C style character arrays. String seems easier.
- 3:06Speaker 2: It is definitely more convenient for like joining text together,
- 3:10Speaker 2: but there's a trade off, especially on boards with limited
- 3:12Speaker 2: RAM like.
- 3:13Speaker 1: The UNO memory issues.
- 3:14Speaker 2: Yeah, string objects can use more memory both flash and RAM,
- 3:18Speaker 2: and worse, heavy use of string manipulation in a complex
- 3:22Speaker 2: sketch can fragment the RAM over time.
- 3:25Speaker 1: Leading to those mysterious crashes.
- 3:26Speaker 2: Again exactly so Sea style character arrays. While needing more
- 3:30Speaker 2: manual handling, you have to manage the memory yourself, can
- 3:33Speaker 2: be much more memory efficient and predictable. They mentioned the
- 3:36Speaker 2: start talk function as an example for parsing Sea style strings.
- 3:40Speaker 1: Good to know the options structuring code is also important.
- 3:43Speaker 2: Functions defining functions, deciding what they return maybe an end,
- 3:47Speaker 2: maybe nothing, void.
- 3:48Speaker 1: What if you need a function to give back like
- 3:50Speaker 1: two or three values.
- 3:52Speaker 2: The practical way, often shown in examples is to have
- 3:55Speaker 2: the function modify global variables rather than trying to return
- 3:58Speaker 2: a complex structure. Maybe but it works.
- 4:01Speaker 1: Okay, then control flowifles switch.
- 4:04Speaker 2: Standard stuff with switch, Remember it needs numeric constants for
- 4:08Speaker 2: the cases, and you must use brake after each case.
- 4:10Speaker 2: Usually otherwise, execution just falls through.
- 4:13Speaker 1: To the next case, ah, right and loops for for
- 4:16Speaker 1: a while yep.
- 4:17Speaker 2: And then operators lots of operators. Your basic math plus
- 4:21Speaker 2: minus times divide.
- 4:22Speaker 1: Increment decrement plus plus plus type. Though the book notes
- 4:25Speaker 1: result result plus one is just as efficient and maybe clearer.
- 4:29Speaker 2: Yeah, result plus plus is common but no real speed
- 4:31Speaker 2: game readability is often better. Then there's modulus.
- 4:34Speaker 1: Percent for remainders useful for checking even nod or wrapping counter.
- 4:38Speaker 2: Super useful, and comparison operators. Yeah, the big one.
- 4:41Speaker 3: Don't mix up it, please don't please don't get if
- 4:44Speaker 3: value five compares value to five, if value five assigns
- 4:47Speaker 3: five to value, and because five is non zero, the
- 4:50Speaker 3: if condition becomes always true.
- 4:52Speaker 1: A nightmare bug defined totally.
- 4:53Speaker 2: Then logical operators in A and D or candy for
- 4:56Speaker 2: combining conditions.
- 4:57Speaker 1: And bitwise operators for fiddling with individual.
- 4:59Speaker 2: Bits right and and dan. But often the helper functions
- 5:03Speaker 2: are easier bitrid bitright, bitset, bit clear, bit much more readable.
- 5:07Speaker 1: Good point operator precedents use parentheses to be sure.
- 5:11Speaker 2: Always good advice, and the book mentions garbage in garbage out.
- 5:15Speaker 2: Check your inputs even if example, skip it for brevity. Also,
- 5:19Speaker 2: watch out for variable overflow.
- 5:21Speaker 1: Where a calculation result is too big for the variable type.
- 5:23Speaker 2: Yep, the ide might not warn you unless you turn
- 5:26Speaker 2: warnings way up. For constants, const is better than hashtag define.
- 5:31Speaker 2: Why's that? Because const variables have a type so the
- 5:34Speaker 2: compiler can check if you're using them correctly. Hashtag define
- 5:37Speaker 2: is just text replacement basically, Plus the compiler often optimizes
- 5:41Speaker 2: constvarrables away if they aren't needed.
- 5:43Speaker 1: Smart Lastly, on basics, board variations matter. Three point three
- 5:48Speaker 1: V versus.
- 5:48Speaker 2: Five V huge difference, and not just voltage but pin
- 5:51Speaker 2: current limits. An UDO pin might handle forty million amps,
- 5:54Speaker 2: but a thirty two bit board pin might only handle
- 5:57Speaker 2: seven million amps.
- 5:57Speaker 1: So you can't just drive an LED directly from any
- 6:00Speaker 1: on any board.
- 6:00Speaker 2: Nope, you have to check the SVATA sheet and form
- 6:03Speaker 2: factors differ too, UNO MKR, Nano zero effcshield compatibility. Lots
- 6:08Speaker 2: of practical details.
- 6:09Speaker 1: Okay, solid foundation. Now how do these boards actually talk
- 6:12Speaker 1: to things? Cereal I two CSBI right, Chapter four.
- 6:15Speaker 2: And thirteen get into this. Cereal is kind of the workhorse.
- 6:18Speaker 2: Flexible talks to computers other devices.
- 6:21Speaker 1: Usually over that USB connection, which also uploads the sketch.
- 6:24Speaker 2: Yep, you start with serial dot begin setting the BOD right, Yeah,
- 6:28Speaker 2: crucial step both ends must match speed or yeah gibberish
- 6:31Speaker 2: just random characters. Yeah, Then cerreal dot print or serial
- 6:35Speaker 2: dot print to send data. A check serial dot available
- 6:39Speaker 2: to see if data has arrived, then Cereal dot read
- 6:42Speaker 2: to get a byte or serial dot parsit serial dot
- 6:45Speaker 2: parse float for numbers.
- 6:47Speaker 1: You need to decide how to structure the data right
- 6:49Speaker 1: text versus binary exactly.
- 6:51Speaker 2: Text is easier to debug, maybe use commas as dilimiters.
- 6:54Speaker 2: Binary is more compact, but you really need to know
- 6:56Speaker 2: the data types on both ends. Functions like low byte
- 6:59Speaker 2: and i bite help with multibyte values.
- 7:02Speaker 1: The IDEs Serial monitor and serial quatter are useful.
- 7:05Speaker 2: Here absolutely monitor for text, plotter for graphing numbers, visually
- 7:09Speaker 2: great for sensors. And there are other terminal programs too,
- 7:12Speaker 2: like qute com.
- 7:12Speaker 1: What if you need more serial ports than the board has,
- 7:15Speaker 1: like on a MOOO, That's where software Cereal comes in.
- 7:17Speaker 2: It's a library that lets you use other digital pins
- 7:20Speaker 2: to simulate a serial port. Not as fast or reliable
- 7:23Speaker 2: as hardware Cereal, but a life saver. Sometimes boards like
- 7:27Speaker 2: the Mega or newer ARM boards often have multiple hardware
- 7:30Speaker 2: serial ports built in.
- 7:31Speaker 1: Okay, moving from talking to the computer to talking between chips.
- 7:35Speaker 2: I two C integrated circuit great protocol uses just two
- 7:39Speaker 2: wires SDA and SEL plus power and ground. You can
- 7:42Speaker 2: connect multiple devices to those same two wires.
- 7:44Speaker 1: How does that work?
- 7:45Speaker 2: Each device needs a unique address. The arduino acts as
- 7:49Speaker 2: the master and it addresses the specific slave device it
- 7:51Speaker 2: wants to talk to, like maybe a sensor A address
- 7:54Speaker 2: serial by five.
- 7:55Speaker 1: A using the wire library YEP.
- 7:57Speaker 2: Wired up begin transmission, wired dot write, wired up in
- 8:00Speaker 2: transmission to send wired dot request FROUM, and wired dot
- 8:03Speaker 2: read to receive sound straightforward. Any catches voltage levels. If
- 8:07Speaker 2: you have a five VR duino and a three point
- 8:09Speaker 2: three v I two C sensor, you absolutely need a
- 8:12Speaker 2: logic level shifter between them, otherwise you risk frying the sensor.
- 8:15Speaker 1: Ah, good warning. The examples show reading e proms connecting
- 8:18Speaker 1: our duenos, even a we nunchuck.
- 8:20Speaker 2: Yeah, the nunchuck uses it two C for its accelerometer.
- 8:22Speaker 2: Cool example.
- 8:23Speaker 1: Okay, then there's SPI Serial peripheral interface.
- 8:26Speaker 2: Right, often faster than it. Two C uses four main
- 8:30Speaker 2: lines Mosai, MISO, SCK and ss or cs.
- 8:34Speaker 1: Master out, slave in, master and slave out, clock and
- 8:36Speaker 1: slave select exactly.
- 8:38Speaker 2: MOSAI and MESA are separate data lines, which helps the speed.
- 8:41Speaker 2: SCK is the clock signal.
- 8:43Speaker 1: How do multiple SPI devices work?
- 8:45Speaker 2: They share Mosai, MISO and SEK, but each slave device
- 8:49Speaker 2: needs its own dedicated slave select SS or JIP select
- 8:52Speaker 2: cspin controlled by the arduino, So.
- 8:55Speaker 1: The arduena pulls one CS line low to talk to
- 8:57Speaker 1: that specific device precisely.
- 8:59Speaker 2: The example of using an SD card reader and a
- 9:01Speaker 2: TFT display together illustrates this well. Both my use SPI.
- 9:05Speaker 2: They share the main three lines, but you need two
- 9:07Speaker 2: separate Arduino pins for their individual CS lines.
- 9:10Speaker 1: Got it. Okay, we know how to program, how communicate.
- 9:12Speaker 1: Now let's get our hands dirty interacting with the physical
- 9:14Speaker 1: world inputs and outputs.
- 9:16Speaker 2: Yeah, this is where it gets fun. Chapters five through
- 9:18Speaker 2: eleven cover this, starting with inputs digital and analog.
- 9:22Speaker 1: Digital is just high or low voltage right.
- 9:26Speaker 2: Digital read after setting the pin with pin mode pin
- 9:30Speaker 2: I nput and remember the voltage level for HGH differs
- 9:34Speaker 2: between three point three V and five.
- 9:36Speaker 1: V boards, and analog is analog.
- 9:38Speaker 2: Reed reads a voltage on an analog input pin and
- 9:41Speaker 2: converts it to a number, usually zero to kenna to
- 9:43Speaker 2: twenty three. Unos have six analog pins, megas have sixteen.
- 9:48Speaker 1: The book covers common inputs like switches potentiometers.
- 9:51Speaker 2: Potentiometers are great examples of analog input and voltage division.
- 9:55Speaker 2: Also photo resistors light sensors that change resistance. You need
- 9:59Speaker 2: a fixed resistor with to create a voltage divider circuit.
- 10:01Speaker 2: Microphones too, Yeah, electro microphone breakouts. You read them with
- 10:04Speaker 2: an analog read but you need to account for the
- 10:06Speaker 2: DC offset in the signal temperature sensors like the analog
- 10:10Speaker 2: TMP thirty six or the digital DS eighteen B twenty
- 10:13Speaker 2: which uses a different protocol called one wire and GPS modules,
- 10:16Speaker 2: those usually communicate over cereal sending streams of text data.
- 10:19Speaker 2: Libraries like tiny GPS plus make parsing that data much easier.
- 10:23Speaker 1: What about needing more analog inputs than the board has
- 10:26Speaker 1: clever trick.
- 10:28Speaker 2: Use a multiplexer chip like the forty five to one
- 10:31Speaker 2: unless you switch one analog pin between multiple inputs. The
- 10:34Speaker 2: book also shows measuring higher voltages using a voltage divider
- 10:38Speaker 2: circuit and calculating the actual voltage and reading IR remote
- 10:41Speaker 2: controls using the I Remote library.
- 10:43Speaker 1: Cool now outputs making things happen.
- 10:46Speaker 2: LED's first the classic, but watch that pin current limit
- 10:50Speaker 2: we mentioned forty mari on Uno, maybe only seven marry
- 10:53Speaker 2: out another's for bright LEDs or lots of immunia transistor
- 10:57Speaker 2: or moss fat to handle the current.
- 10:59Speaker 1: What about those fancy addressable LEDs NeoPixels very popular?
- 11:03Speaker 2: Use a library like a to fruit NeoPixel. You tell
- 11:05Speaker 2: each pixel what color it should be, then call the
- 11:07Speaker 2: show function to update the whole strip at once.
- 11:09Speaker 1: They mention things like color HSV and gamma thirty two.
- 11:12Speaker 2: Yeah, color HSV gives you HU saturation value control, which
- 11:15Speaker 2: could be more intuitive than RGB sometimes, and gamma thirty
- 11:18Speaker 2: two corrects the brightness so colors look more natural to
- 11:20Speaker 2: our eyes. Big consideration power Lots of new epixels need
- 11:24Speaker 2: a separate BF power supply.
- 11:26Speaker 1: Okay, what about LED matrices? Lots of simple LEDs.
- 11:29Speaker 2: Use techniques like multiplexing or Charlie plexing to control many
- 11:33Speaker 2: LEDs with fewer pins. The book explains the concepts and wiring.
- 11:36Speaker 2: It can get complex, especially animating Charlie plex displays and
- 11:40Speaker 2: multiplexing can draw a surprising amount of power.
- 11:42Speaker 1: Sometimes seven segment displays for numbers.
- 11:45Speaker 2: Yep again often multiplexed. Understanding common cathode versus common and
- 11:49Speaker 2: ode is key, but using an I two C driver
- 11:52Speaker 2: chip like the HT sixteen K thirty three makes it
- 11:55Speaker 2: much simpler.
- 11:55Speaker 1: Just two wires plus power moving Beyond simple lights, displays
- 11:59Speaker 1: like LCA.
- 12:00Speaker 2: Text LCDs are common. Use the Liquid Crystal library, print text,
- 12:04Speaker 2: set the curser position scroll. You can even create custom characters.
- 12:07Speaker 1: What about graphical displays olds color LCDs.
- 12:10Speaker 2: They offer much more detail, but yet more complex wiring.
- 12:13Speaker 2: Usually monochrome O leads often use I two C or
- 12:16Speaker 2: SPI libraries like Adafruit SSD one three zero six are common.
- 12:20Speaker 2: Color LCDs typically use SPI like the ST seven seven
- 12:23Speaker 2: seven three five or ST seven seven eight nine. Types. Again,
- 12:26Speaker 2: with dedicated libraries, is.
- 12:27Speaker 1: It hard to switch between display types?
- 12:29Speaker 2: Sometimes not. Adafruit, for instance, tries to keep their graphics
- 12:32Speaker 2: library APIs similar, which helps. The main trade off is
- 12:35Speaker 2: often monochrome versus color, cost, memory usage, power draw okay.
- 12:40Speaker 1: Visual output covered. Let's make things move.
- 12:42Speaker 2: Servos easiest way to get precise rotational movement. Use the
- 12:46Speaker 2: Serbo library attached to a pin tell at an angle
- 12:48Speaker 2: with Servo dot write.
- 12:50Speaker 1: Simple scoops are easy, but there was a timer conflict warning.
- 12:53Speaker 2: Uh yes, good catch on the un The servil library
- 12:57Speaker 2: uses Timer one. Dot analog rite on pins No. Ten
- 13:00Speaker 2: also uses Timer one, so you can't use servos NPWM
- 13:03Speaker 2: on those specific bins at the same time hardware limitation.
- 13:07Speaker 1: Good to know DC motors like in Little Robots.
- 13:10Speaker 2: Right, They need more power than an Ardueno pin can supply,
- 13:13Speaker 2: and you usually want to control direction too, so you
- 13:15Speaker 2: need external drivers transistors for simple on off or h
- 13:19Speaker 2: bridges like the L two ninety three or L two
- 13:21Speaker 2: ninety eight for speed and direction control using PWM motor
- 13:24Speaker 2: shields bundle this up neatly.
- 13:26Speaker 1: The book shows controlling motors based on sensors, yeah, like.
- 13:29Speaker 2: Using photo resistors to make a simple light following robot.
- 13:31Speaker 1: Classic project stepper motors for more precise positioning.
- 13:36Speaker 2: Often driven using dedicated driver boards like the Easy Driver
- 13:40Speaker 2: for bipolar steppers. The duino tills the driver the direction
- 13:44Speaker 2: and when to step, and the driver handles the tricky
- 13:46Speaker 2: coil energizing sequences. You might not even need the standard
- 13:50Speaker 2: stepper library with that approach.
- 13:52Speaker 1: Interesting. What about sound?
- 13:54Speaker 2: Simplest way is the tone function. Connect a speaker or
- 13:58Speaker 2: piezo buzzer to a digital pin, give it a frequency
- 14:01Speaker 2: in duration beep.
- 14:02Speaker 1: Can you play melodies?
- 14:03Speaker 2: Sure? Store the note frequencies and durations in a raise,
- 14:06Speaker 2: then loop through them using tone. The book even shows
- 14:09Speaker 2: generating tones with more precise microsecond timing.
- 14:12Speaker 1: MIDI output two YEP.
- 14:14Speaker 2: Sending many messages out the serial TX pin. Just remember
- 14:17Speaker 2: to disconnect anything connected to pin one TX when you
- 14:20Speaker 2: upload a new sketch, otherwise the uproad.
- 14:22Speaker 1: Might fail and complex sounds the odd winosketch.
- 14:25Speaker 2: Ah yeah, that's a NEAT one, a software synthesizer using
- 14:28Speaker 2: potentiometers for control, but the sources mentioned is likely only
- 14:32Speaker 2: for eight bit boards like the UNO. A good reminder
- 14:34Speaker 2: that some low level code isn't easily portable.
- 14:37Speaker 1: So much interaction, but timing is crucial for.
- 14:40Speaker 2: Orchestrating all this absolutely to chapter twelve and eighteen, focus
- 14:44Speaker 2: on time. The basic pause is delay stops everything for milliseconds,
- 14:49Speaker 2: delay microseconds for shorter pauses.
- 14:51Speaker 1: There's also a pulse.
- 14:52Speaker 2: Ent yeah, for measuring how long a digital pulse. Lasts useful,
- 14:56Speaker 2: but it has limitations on the range and accuracy of
- 14:59Speaker 2: pulses that can bear reliably.
- 15:00Speaker 1: But delay stops everything, right, that's often bad.
- 15:03Speaker 2: It often is. That's why the milli's function is so important.
- 15:07Speaker 2: It returns the number of milliseconds since the board started.
- 15:10Speaker 2: Use it for non blocking timing, like.
- 15:11Speaker 1: The blink without delay example.
- 15:13Speaker 2: Exactly check the current millise, compare it to when the
- 15:16Speaker 2: last action happened, and if enough time has passed, do
- 15:19Speaker 2: the action again and record the new time. This lets
- 15:21Speaker 2: your loop keep running quickly, checking sensors, handlink communication, and
- 15:26Speaker 2: blinking the LED seemingly all at once.
- 15:29Speaker 1: Much better. What about scheduling tasks for later?
- 15:31Speaker 2: The time and time alarms libraries are great for that.
- 15:34Speaker 2: You can set alarms to trigger functions once time once
- 15:38Speaker 2: or repeatedly time repeat any catches. You must call alarm
- 15:41Speaker 2: dot delay frequently in your loop. That's the function that
- 15:44Speaker 2: actually checks if any alarms are due. If you don't
- 15:46Speaker 2: call it, your alarms won't fire, and there's usually a
- 15:48Speaker 2: limit to how many alarms you can have active, like
- 15:50Speaker 2: six on AVR boards by default.
- 15:52Speaker 1: Okay. The book also mentions hardware timers under the hood.
- 15:56Speaker 2: Yeah, the micro controller ship itself has dedicated hardware timers. Yeah.
- 16:00Speaker 2: On the UNO's eighty Mega three twenty eight timers zero
- 16:03Speaker 2: is used by Millie's delay and PWM on pins five
- 16:07Speaker 2: to six. Timer one is for PWM on pins nine
- 16:10Speaker 2: to ten, and the SERVERO Library Tier II is PWM
- 16:14Speaker 2: on pins three eleven.
- 16:15Speaker 1: Ah, So that's the hardware reason for the servo PWM
- 16:18Speaker 1: conflict on pins nine to ten. They both need timer
- 16:21Speaker 1: one exactly.
- 16:22Speaker 2: Knowing this helps diagnose weird issues. You can even manipulate
- 16:25Speaker 2: the timer registers directly for super precise PWM or timing,
- 16:29Speaker 2: but that's getting advanced.
- 16:30Speaker 1: There was also something about faster analog reads.
- 16:33Speaker 2: Right, you can change the ADC analog to digital converter
- 16:36Speaker 2: clock speed standard and allogreed takes about one hundred and
- 16:38Speaker 2: ten microseconds. By tweaking a register, you can get it
- 16:41Speaker 2: down to maybe seventeen microseconds on a sixteen megawords board.
- 16:44Speaker 1: Wow, that's a huge speed up, useful for audio, perfect for.
- 16:47Speaker 2: Things like audio sampling or capturing other fast changing signals.
- 16:51Speaker 1: And the Watchdog timer for sleep YEP.
- 16:53Speaker 2: It's mainly designed to reset the board if the code hangs,
- 16:56Speaker 2: but you can also use it to put the board
- 16:58Speaker 2: into a low power sleep for sure fixed periods fifteen
- 17:01Speaker 2: milliseconds up to eight seconds. You can loop these sleeps
- 17:04Speaker 2: for longer low power delays.
- 17:06Speaker 1: Okay, we've got code communication IO timing. Yeah, what about
- 17:12Speaker 1: connecting to the big wide world? Wi Fi and Ethernet?
- 17:16Speaker 2: Chapter fifteen territory opens up huge possibilities. Ethernet is wired
- 17:20Speaker 2: Wi Fi is wireless need specific hardware, of.
- 17:23Speaker 1: Course, like an Ethernet shield or boards with built in
- 17:26Speaker 1: Wi Fi exactly.
- 17:27Speaker 2: Libraries like Ethernet or waifena handle the low level stuff.
- 17:30Speaker 2: The super cheap espaight to sixty six modules are also mentioned,
- 17:33Speaker 2: amazing value for adding Wi Fi, though maybe a bit
- 17:36Speaker 2: more fiddly to get started with programming them initially.
- 17:39Speaker 1: So Ardno can be a client or a server on
- 17:41Speaker 1: the network. What does being a client involve?
- 17:44Speaker 2: Initiating connections? Sending simple UDP messages for example, or very
- 17:48Speaker 2: commonly acting like a web client, making requests to web
- 17:51Speaker 2: servers to.
- 17:51Speaker 1: Get data like fetching weather data or stock prices.
- 17:54Speaker 2: Or the example in the book getting the current location
- 17:57Speaker 2: of the International Space Station from the open Notify API.
- 18:01Speaker 2: The key is making the request and then parsing the response.
- 18:04Speaker 1: You get back extracting the actual numbers or texts you
- 18:07Speaker 1: need from the HTML or JSON right.
- 18:09Speaker 2: The book shows examples for strings, floats, iNTS. It also
- 18:13Speaker 2: covers requesting XML data, sending data using HTTP post like
- 18:18Speaker 2: filling out a web form, and getting the time using NTP,
- 18:21Speaker 2: even sending tweets YEP, usually via a proxy service like
- 18:25Speaker 2: think speak that handles the authentication and for IoT stuff,
- 18:28Speaker 2: MQTT is.
- 18:29Speaker 1: Key message queuing telemetry transport.
- 18:32Speaker 2: That's the one. Using a library like pubsubclient, your Arduino
- 18:36Speaker 2: can publish data like sensor readings to a central broker
- 18:39Speaker 2: or subscribe to topics to receive commands or data from
- 18:41Speaker 2: other devices. Very efficient for IoT.
- 18:44Speaker 1: Okay, what about acting as a server.
- 18:46Speaker 2: That means your Dueno listens for incoming connections. Most common
- 18:49Speaker 2: is setting it up as a web server using the relevant.
- 18:51Speaker 1: Library, so you could type its IP address into a
- 18:54Speaker 1: browser and see a page exactly.
- 18:56Speaker 2: Your Dueno sketch handles the incoming request, figures out what
- 19:00Speaker 2: page was asked for, and sends back HTML to the browser.
- 19:03Speaker 1: Could you control Arduino pins from that web page?
- 19:06Speaker 2: Absolutely? The book shows handling incoming form data like button
- 19:10Speaker 2: clicks on the web page and parsing that data to
- 19:13Speaker 2: turn pins high GH or low W.
- 19:15Speaker 1: For instance, what if the web page has a lot
- 19:17Speaker 1: of text memory issues?
- 19:19Speaker 2: Again, definitely, that's where program and the f macro become
- 19:22Speaker 2: absolutely essential. You store all that constant HTML text and
- 19:26Speaker 2: flash memory, saving precious RAM. You really have to do
- 19:29Speaker 2: this for non trivial server pages on an UNO got it?
- 19:32Speaker 1: Are there other wireless options besides Wi Fi?
- 19:34Speaker 2: The book briefly mentions modules like the RFM sixty nine
- 19:38Speaker 2: HCW that use unlicensed radio frequencies good for point to
- 19:41Speaker 2: point or simple networks over shorter distances use libraries like Radiohead.
- 19:45Speaker 2: Also XB modules which are powerful but often more complex.
- 19:48Speaker 1: To configure, and Bluetooth Low Energy BL using.
- 19:51Speaker 2: The Rdueno BLE library. Let's shore r Dueno act as
- 19:54Speaker 2: a BL peripheral like a sense of Your phone can
- 19:56Speaker 2: connect to or connect to other BLE devices qew.
- 19:59Speaker 1: That's a lot capability. Finally, let's talk practicalities, optimization, troubleshooting.
- 20:05Speaker 1: The stuff in the appendices crucial stuff.
- 20:07Speaker 2: Understanding the build process helps preprocessor compiler AVR GCC for
- 20:13Speaker 2: many ar duenas, linker uploader abdude. Knowing these steps exists
- 20:17Speaker 2: demystifies things a.
- 20:18Speaker 1: Bit and memory management. We keep coming back.
- 20:21Speaker 2: To that because it's critical on small devices. The book
- 20:23Speaker 2: shows a function to check free RAM on AVR boards
- 20:26Speaker 2: and reiterates use progemm for constant numeric data, use f
- 20:31Speaker 2: text for constant text data. Saves RAM on ARM boards.
- 20:34Speaker 2: Constant often does the job automatically.
- 20:36Speaker 1: Okay, troubleshooting code won't compile.
- 20:39Speaker 2: Check the error messages, and remember the actual error is
- 20:41Speaker 2: often on the line before the highlighted one. Missing semicolons,
- 20:44Speaker 2: typos case sensitivity, bad comments, using keywords as variable names,
- 20:49Speaker 2: common mistakes. Compile often, and.
- 20:50Speaker 1: If it compiles but doesn't.
- 20:52Speaker 2: Work, serialed up, print as your best friend. Print out
- 20:54Speaker 2: variable values. Print messages to see where your code is
- 20:57Speaker 2: actually going. Build complex things incrementally.
- 20:59Speaker 1: Test each piece hardware troubleshooting.
- 21:02Speaker 2: Check connections meticulously. Use a multimeter. Wrong voltages are deadly
- 21:06Speaker 2: short circuits too. Test components individually. Watch polarity on things
- 21:10Speaker 2: like LEDs, dios, transistors, ices, resistors. Most capacitors are non polarized.
- 21:15Speaker 2: Breadboards help definitely for prototyping. Fritzing for diagrams, and don't
- 21:19Speaker 2: forget snubber.
- 21:21Speaker 1: Diods for motors and relays.
- 21:22Speaker 2: Yes, inductive loads create voltage spikes when turned off. A
- 21:26Speaker 2: simple diode across the load gives that spike a safe path,
- 21:29Speaker 2: protecting your r aduenopin super important.
- 21:31Speaker 1: Final practical tips, read the data sheet.
- 21:34Speaker 2: Always, especially for maximum ratings. Understand the code U six
- 21:38Speaker 2: permissions from the book. Using snippets is fine. Wholesale copying
- 21:42Speaker 2: isn't be careful what external power supplies.
- 21:45Speaker 1: Wow, Okay, that was a really comprehensive dive through these
- 21:48Speaker 1: are Dueno cookbook excerpts. We covered a.
- 21:49Speaker 2: Ton really did. From the core programming concepts structured data
- 21:53Speaker 2: control flow operators, right through communication protocols like serial IT,
- 21:57Speaker 2: two C and SPI.
- 21:58Speaker 1: Then getting hands on with inputs like sensors and switches
- 22:01Speaker 1: and outputs like LED's displays, motors.
- 22:04Speaker 2: Sound mastering time with Millie's and alarms, digging into hardware timers,
- 22:08Speaker 2: even speeding up analog reads.
- 22:10Speaker 1: And connecting outwards with Ethernet and Wi Fi, acting as
- 22:13Speaker 1: clients and servers using MQTT plus other wireless tech, and.
- 22:18Speaker 2: Wrapped up with vital optimization techniques especially for memory and
- 22:22Speaker 2: solid troubleshooting advice for both software and hardware bugs.
- 22:26Speaker 1: It's pretty amazing how these sources lay out practical recipes
- 22:30Speaker 1: for tackling quite complex tasks with these little micro controller boards.
- 22:34Speaker 2: Yeah, it breaks it down into manageable steps, showing you
- 22:37Speaker 2: the libraries, the functions, and crucially those practical gotchas like
- 22:41Speaker 2: timer conflicts or voltage levels.
- 22:43Speaker 1: So for you listening, this deep dive should give you
- 22:45Speaker 1: a really solid map of the practical techniques available. You've
- 22:48Speaker 1: seen recipes for everything from reading a button to hosting
- 22:52Speaker 1: a web page to driving a robot arm.
- 22:54Speaker 2: So here's a final thought to take away. You've now
- 22:57Speaker 2: seen how you can combine sensors to perceive the world,
- 23:00Speaker 2: actuators and displays to effect it, communication to connect it,
- 23:03Speaker 2: and timing to orchestrate it, all using these different ingredients
- 23:07Speaker 2: from the cookbook. What kind of truly interconnected may be
- 23:09Speaker 2: unexpected responsive project could you build? Now? What surprising interaction
- 23:14Speaker 2: could you create by mixing these capabilities