Knowing how to properly format your code is essential to having a program compile and run correctly. The set of rules defining how to format, spell, and structure your code is known as “syntax,” and it’s what we cover in this episode of Adventures in Science as we continue talking about computer science. We look at the history of the C and C++ languages and how to apply syntax rules to an Arduino program.
This week in Adventures in Science, we examine the various data types in Arduino and how to use literals and variables. While there are only 3 fundamental data types in C, Arduino supports many more. You can also extend various data types by adding keywords like “long” to create a “long int” that uses 4 bytes (instead of 2 in most systems).
This week on Adventures in Science, we look at the various arithmetic operators in C and C++, specifically, as they’re used in the Arduino environment. There are only 6 main operators: assignment, addition, subtraction, multiplication, division, and modulo. We also look at compound assignment operators; how they can be used to perform a math operation on a variable and then store the result back in the same variable.
We examine the ever-important conditional statement, which for C, takes the form of if/else/then. In order to use them effectively, you’ll need to know how to use the relational operators, which compare two numbers (e.g. are two numbers equal?). Knowing these can help you do things like see if a button has been pushed in Arduino.
We go over the basic Boolean operators in C and how to use them to make compound conditional statements. When dealing with Boolean logic, we must assume that variables can only have one of two values: true or false. From there, we have three fundamental operators: NOT, AND, OR. We can combine them to make other operations, like exclusive OR (XOR). Using these operators, we can make compound conditional statements to do things like look for the moment when a button was pushed.
Let’s look at loops in Arduino. Specifically, we look at “while,” “do while,” and “for” loops and how to apply them in our programs. In essence, loops allow us to execute chunks of code repeatedly without needing to copy and paste. They also change the flow of the program, and we can change the way loops execute by modifying their conditions as well as using the “break” and “continue” statements.
LIDAR, which is either a mashup of “laser” and “radar” or an acronym for “light detection and ranging” (depending on whom you ask), is the method of shooting a laser at an object and measuring the time it takes for that reflection to return to a receiver. With it, we can measure distances, determine the speed of moving cars, and map terrain. Here, we look at how LIDAR works and how it can be applied to robots to give them a means to detect objects.
Rotary encoders are useful tools for measuring rotation on a shaft. They come in many different forms, including optical, mechanical, and magnetic. In this video, we show you how they work and how to use them on DC motors to ensure that a robot drives in a straight line for a set distance.
The Global Positioning System (GPS) is a collection of satellites, each containing a powerful and precise atomic clock, that broadcasts their time every 30 seconds. Handheld receivers, like your smartphone, can collect this data and perform calculations to figure out their position on the surface of the Earth. In this episode, we talk about how GPS works and how you can use a receiver to obtain time, latitude, longitude, and altitude data with an Arduino. From there, your robot project could know its location and how to drive somewhere.
A magnetometer is any instrument that can be used to measure magnetic fields. Developments in semiconductor and microelectromechanical systems (MEMS) in the past few decades have afforded us digital magnetometers that can be used to take precise measurements of these fields. Because the Earth acts as a giant magnet, we can use magnetometers to find the direction of the Magnetic North Pole. This could be extremely useful on robots that need to determine a heading to, say, autonomously navigate a course.
For the first time in the history of SparkFun’s Autonomous Vehicle Competition (AVC), we’ll have a separate 1 pound plastic ants division. These are combat bots made mostly out of plastic (the intention is for competitors to 3D print their chassis). We have combat bot veteran, Jamie Leben, help explain the different types of bot weapons and chassis types as well as give us some tips for making them out of plastic.
Learning how to control motors and drive your robot is the first step in creating your combat bot. We look at how to read a pulse width signal from an RC receiver using an Arduino and convert that into a PWM signal for driving motors. We use only 1 channel in this video, as mixing channels for steering is saved for another episode.
We read 2 channels from an RC hobby receiver and mix them together to give steering to our robot. We use 1 control stick to move the robot forward and back as well as turn left and right in a control scheme known as “arcade drive.” Additionally, former AVC combat bot competitor, Erik Josh, joins us to talk about his cardboard box-based bot.
We bring back Jamie Leben (IT Works, Loveland Creatorspace) to talk about some of the design considerations for plastic ant combat bots. He covers some of the basics, like being able drive upside down, and gives us some good tips on where to place most of your weight and how to design a cover. Jamie even provides a wedge bot 3D model for anyone to modify and print!
Let’s combine everything together and make a real, working combat bot! In this episode, we 3D print a wedge bot chassis, solder up the electronics, and program the onboard Arduino for “arcade drive.” By the end, we have a bot that’s ready to compete!
Go from blinking an LED to virtual prototyping in seven hours and still have time to eat lunch! This class is for anyone who has never played around with Arduino before and those who have played around a little bit but aren’t entirely sure what it’s all about. It’s easier than you think! We’ll put together basic single component electrical circuits that will teach you about analog and digital, input and output, and basic programming concepts such as “if” statements. We’ll also practice basic serial communication, and briefly cover basic virtual prototyping using Fritzing (www.fritzing.org). In case you haven’t noticed,…
Live stream from http://twitch.tv/adafruit with a demonstration of controlling a Circuit Playground board with Python using the Firmata protocol. Deep dive into adding custom Firmata commands into Arduino and Python code.
Live stream originally on http://twitch.tv/adafruit working on a Python library for the MCP3008 analog to digital converter with the Raspberry Pi. Discusses the structure of python libraries, how to talk to SPI devices, and details on publishing a library to the Python package index.