POPULARITY
Preshow Mausritter, CY_BORG Quondam Follow-up Capital letter test is a foolproof way of sorting AIs from humans Onderwerpen Re #593: Elon Musks Neuralink krijgt FDA-goedkeuring voor tests hersenchip op mensen Signpost doet overname en mag 440.000 laptops leveren aan het Katholiek onderwijs Smartschool Foto’s & Planner Tips Toon: Silo (Apple TV+) & Fritzing
We like to use our Pretty Pins generator to make lovely and *accurate* diagrams of dev boards. It starts with the Fritzing object (which is generated from the original Eagle files), and then cross references the Arduino and CircuitPython variant definition file to get the true pin names of each exposed pad and signal. Finally it looks up the multiplexing functionality for that gpio pin on the chip in a spreadsheet to generate the lovely label boxes. The pinmux spreadsheet has to be made by hand but we finally got around to doing the massive table used for the SAMD51 so we can now generate Pretty Pins for all SAMD51-based designs. You can see the CSV here https://github.com/adafruit/PrettyPins/blob/main/samd51pins.csv Visit the Adafruit shop online - http://www.adafruit.com #adafruit #samd51 #circuitpython ----------------------------------------- LIVE CHAT IS HERE! http://adafru.it/discord Adafruit on Instagram: https://www.instagram.com/adafruit Subscribe to Adafruit on YouTube: http://adafru.it/subscribe New tutorials on the Adafruit Learning System: http://learn.adafruit.com/ -----------------------------------------
Fritzing lets you build a circuit from breadboard to PCB #adafruit #collinslabnotes Shop PCBs @ Adafruit: https://www.adafruit.com/?q=PCB&sort=BestMatch Visit the Adafruit shop online - http://www.adafruit.com ----------------------------------------- LIVE CHAT IS HERE! http://adafru.it/discord Adafruit on Instagram: https://www.instagram.com/adafruit Subscribe to Adafruit on YouTube: http://adafru.it/subscribe New tutorials on the Adafruit Learning System: http://learn.adafruit.com/ -----------------------------------------
This week's Desk of Ladyada is a little light on hardware, as we spent some of the weekend outside and the rest on some software hacking! We used to get very nice pinout diagrams made for our boards by a fellow named Pighixxx. They ended up doing a crowdfunding project that didn't work out and they stopped replying to emails. We like having pinout diagrams but also know that if it's too hard, we won't keep up. Check out Bill Binko's video for a manual technique https://blog.adafruit.com/2019/07/11/automating-the-making-of-beautiful-pinout-diagrams-for-microcontroller-boards-documentation-at_makers/ Much like our Fritzing tool which can generate 99%-ready fritzing objects, having an automated way is best! We looked at the Sparkfun Graphical Datasheet tool (https://github.com/sparkfun/Graphical_Datasheets) and its a step in the right direction - but we didn't want to have to create a CSV for each board because I am very lazy! So we're experimenting with using the Fritzing file, circuitpython pin file, and a single chip-pinout spreadsheet to help us get something 'good enough' even if it isn't as beautiful as the Pighixxx ones. I'll talk about some of the tools we ended up using and why we still need a human to wrap it up. We also made the first draft of an RP2040-powered 3x4 macro pad with rotary encoder and OLED that we'll show off. The Great Search - Alternatives to TL074 Op-Amps! https://www.digikey.com/short/85mv3mrm We noticed a few synth-makers getting worried about not being about to source TL074 quad op-amps! https://twitter.com/theavalkyrie/status/1381800012162666497 https://twitter.com/otdispace/status/1382920010042081283 We thought we'd spend this Great Search looking at the TL074 - why its so great and what to look for in an alternative. We asked 'guest' - the co-designer of the x0xb0x to drop some knowledge on us: the 074 is pretty much the toyota corolla of opamps. its not the best at anything in particular, but pretty good at everything. its the second cheapest opamp out there, comes in dip and soic, has relatively low current consumption, low distortion, and reasonable bandwidth and slew rate. the noise is ok-ish low, but the thing that really makes it an all around performer is the low bias current. its down in the pA range, which means you can use it for S/H or VCO,VCF, etc that require a range of currents down to the nAs. a lot of people used the LM358 because it is the cheapest opamp, but it has high bias current. the 074 can also handle high voltage rails which helps with SNR. it was designed for audio use, and was one of the first real mass market opamps back in the late 70s (if i recall correctly). the 741 was the first, and this was meant as an improvement over that. the 074 and 084 were made at the same time, and 074s were selected for lower noise, better distortion, and lower offset voltage, and then marketed at the audio market. the 084 was sold to everyone else. Who doesn't love the TL074? Apparently a lot of people - so let's look at a backup-option. It may not be as cheap/good but maybe it'll be in stock! #adafruit #digikey #thegreatsearch Visit the Adafruit shop online - http://www.adafruit.com ----------------------------------------- LIVE CHAT IS HERE! http://adafru.it/discord Adafruit on Instagram: https://www.instagram.com/adafruit Subscribe to Adafruit on YouTube: http://adafru.it/subscribe New tutorials on the Adafruit Learning System: http://learn.adafruit.com/ -----------------------------------------
Lista de los temas para este episodio: Episodio #87 Linux Connexion con Adrián Perales Próximo episodio: Creative Commons Curso Maker School de Kreitek con Arduino, Raspberry Pi, impresión 3D con FreeCAD y corte láser con InkScape. Fritzing para crear esquemas eléctricos en proyectos Arduino. Nueva versión de ShotCut Eventos podcasteros: Podcast Days y Maratón Pod Recuerda que puedes contactar conmigo de las siguientes formas: Twitter: https://twitter.com/podcastlinux Mastodon: https://mastodon.
Despite a myriad of technical issues, Dick and Skippy bull through a fun Friday. Highlights include giving tickets to Taste Fest (www.conroe.org) and the Morning Duo manage to talk non-stop for nearly an hour while [...]
If Statement (and else-if), Comparison Operators and Conditions In the last lesson, we learned about the if statement. The if statement was the perfect choice for setting up instructions to run only when certain conditions were met. “If 30 seconds has passed – stop the heating element” or “If the sensor perceives a wall – turn 180 Degrees”. This lesson will expand on this amazingly useful function and show you how to stack different conditions to satisfy the flexibility you want in your designs. If you like this tutorial, click here to check out FREE Video Arduino course – thousands of people have really enjoyed it. You Will Need Potentiometer (doesn’t matter what resistance range) 220 Ohm Resistor LED (any color) Jumper Wires (3) Alligator Clip Dull machete with wood handle Step-by-Step Instructions Place the potentiometer in the breadboard. Place a jumper wire from one of the outside leads of the potentiometer to the 5V pin on Arduino. Place a jumper wire from the other outside lead of the potentiometer to one of the GND pins. Place the final jumper wire from the center pin of the potentiometer to the A0 pin. Connect either side of the 220 ohm resistor to pin 13. Connect the short leg of the LED to GND (the GND pin next to pin 13 is the most convenient). Attach the other leg of the resistor to the long leg of the LED. Plug your Arduino into your computer with the USB cable. Open the Arduino IDE. Open the sketch for this section. Click the Verify button (top left). The button will turn orange and then blue once finished. Click the Upload button. The button will turn orange and then blue when finished. Open up the Serial Monitor window. Tools > Serial Monitor. Adjust the potentiometer and watch as the LED turns on and off based on the knob position. If Then Statement Conditionals Set up This image built with Fritzing. /* Conditionals - If statement This example demonstrates the use of if() statements. It reads the state of a potentiometer (an analog input) and turns on an LED only if the potentiometer goes above a certain threshold level. It prints the analog value regardless of the level. The circuit: * potentiometer connected to analog pin 0. Center pin of the potentiometer goes to the analog pin. side pins of the potentiometer go to +5V and ground * LED connected from digital pin 13 to ground * Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example. created 17 Jan 2009 modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/IfStatement */ // These constants won't change: const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize serial communications: Serial.begin(9600); } void loop() { // read the value of the potentiometer: int analogValue = analogRead(analogPin); // if the analog value is high enough, turn on the LED: if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } // print the analog value: Serial.println(analogValue); delay(1); // delay in between reads for stability } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 /* Conditionals - If statement This example demonstrates the use of if() statements. It reads the state of a potentiometer (an analog input) and turns on an LED only if the potentiometer goes above a certain threshold level. It prints the analog value regardless of the level. The circuit: * potentiometer connected to analog pin 0. Center pin of the potentiometer goes to the analog pin. side pins of the potentiometer go to +5V and ground * LED connected from digital pin 13 to ground * Note: On most Arduino boards, there is already an LED on the board connected to pin 13, so you don't need any extra components for this example. created 17 Jan 2009 modified 9 Apr 2012 by Tom Igoe This example code is in the public domain. http://www.arduino.cc/en/Tutorial/IfStatement */ // These constants won't change: const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 400; // an arbitrary threshold level that's in the range of the analog input void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize serial communications: Serial.begin(9600); } void loop() { // read the value of the potentiometer: int analogValue = analogRead(analogPin); // if the analog value is high enough, turn on the LED: if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } // print the analog value: Serial.println(analogValue); delay(1); // delay in between reads for stability } Discuss the Sketch In this sketch we measure voltage at an analog pin from 0 to 1023 – this voltage changes based on where the knob of the potentiometer is set. We then define a threshold value somewhere in this range, let’s pick the number 400. When the value measured at the analog pin is above 400, we turn on the LED at pin 13, when the voltage is below 400 we turn the LED off. It’s as easy as that. Make sure you read the sketch and try to figure out what is taking place before moving on. This program might look long to you – the previous ones were a bit shorter. A good way to approach any program long or short is to cut it up into chunks and only consider pieces of it at a time. The first chunk in this sketch is the multi-line comments that clearly describe: What the program will do Generally how the program will accomplish it How to set up the circuit and the components you will need Any pertinent notes The license the program is released under (if any) The author, date and version number This might seem like a lot of stuff – but I would recommend you do the same thing for your programs! This information will not only help you understand what the heck you intended when you wrote the program but if you make the program available for others then your comments will help them as well. Some of the functions that are now integrated into the Arduino IDE were created by people just like you – they had a problem, they found a solution with some well-written code, they made it available to all the Arduino users in the world – and everybody else found it useful – and before you know it your code is famous and you win the Nobel peace prize. Enough of this tirade, let’s move onto the first block of code that will be executed by the Arduino. const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 400; // an arbitrary threshold level that’s in the range of the analog input 1 2 3 4 5 const int analogPin = A0; // pin that the sensor is attached to const int ledPin = 13; // pin that the LED is attached to const int threshold = 400; // an arbitrary threshold level that’s in the range of the analog input Notice that all the variables have const in front of them. This keyword stands for constant. A constant is classified as a qualifier – it adjusts the behavior of the variable being declared. It is similar an adjective in a sentence – “The squishy material,” squishy qualifies what the material will behave. It might seem counterintuitive to the whole point of variables, but the constant qualifier will stop the variable from changing throughout your program. It protects the value from start to finish. Why do this? It protects you from unintentionally writing a new value to the variable. It happens more often than you might think – I recommend using constants when the variable will not change in the program. The integer constants we declare are pretty straightforward. The variables analogPin and ledPin are those pins the potentiometer and LED will be attached to on the Arduino board. Threshold is the arbitrary number chosen as the condition to turn our LED on or off. The next block of code is setup(). Here, we have to set the mode of a pin and set up serial communications. void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize serial communications: Serial.begin(9600); } 1 2 3 4 5 6 7 8 9 10 11 void setup() { // initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // initialize serial communications: Serial.begin(9600); } Recall that all pins are by default set to INPUT, so we do not have to explicitly set the pin mode for our analogPin A0 as an INPUT – though I would argue it is best to do so for clarity. You should have serial communication down pat. We use the begin() function from the Serial library with a baud rate of 9600. Now that we have things setup, let’s get into the loop(). The first line of code we encounter reads from the value at the analog pin A0 and assigns this value to an integer variable called analogValue. int analogValue = analogRead(analogPin); 1 int analogValue = analogRead(analogPin); To do this, we use the analogRead() function. Recall that analogRead() will return a value between 0 and 1023. This value will change as we adjust the potentiometer. This line of code is checking the position of the potentiometer every time through the loop(). The next thing we want to do is compare the value we just read from the analog pin to our threshold value. The if-else statement is perfect for this. if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } 1 2 3 4 5 6 7 8 9 if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } else { digitalWrite(ledPin, LOW); } You have seen the if statement before, now we add an else statement. The if statement checks a condition in the parenthesis, if it is TRUE, then the code in the curly brackets is executed – if the condition is not met (FALSE), then it moves to the else statement. Consider this pseudocode: if(apple is NOT rotten) { } else { } 1 2 3 4 5 if(apple is NOT rotten) { } else { } You can see that the else statement gives you control over what to do when the condition in the if statement is not met. In a later lesson we will talk about the else-if statement which will offer even further control over conditions. Explanation of iF-Then Statements In this example the condition we are interested in is: In this example the condition we are interested in is thus… analogValue > threshold 1 analogValue > threshold If this is TRUE we turn the LED on by using the digitalWrite() function: if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } 1 2 3 4 5 if (analogValue > threshold) { digitalWrite(ledPin, HIGH); } If this condition is FALSE we turn off the LED by executing the code inside the curly brackets of the else statement: else { digitalWrite(ledPin, LOW); } 1 2 3 4 5 else { digitalWrite(ledPin, LOW); } Before we continue discussing the sketch, let’s do a quick overview of Comparison Operators. The condition set in an if-else statement will use what are called comparison operators. The list of comparison operators on the Arduino Reference page is as follows: == (equal to) != (not equal to) < (less than) > (greater than) = (greater than or equal to) These operators offer a broad spectrum of comparisons to use. It’s vital to pay close attention to the syntax of the comparison operators. Accidentally dropping an equal sign, or typing a > instead of a < is easy to do, and usually leaves you scratching your head when the program acts differently than you might have expected. Now that we have turned the LED on or off depending on the position of the potentiometer, let’s see exactly what values are being read. We want to do this to ensure the program is doing what we think it should and also to make sure our potentiometer (sensor) is working properly. // print the analog value: Serial.println(analogValue); 1 2 3 // print the analog value: Serial.println(analogValue); This line of code uses the println() function from the Serial library – which (as you know by now) sends the values from the Arduino to your computer. Adjust your potentiometer and watch the values change in the Serial Monitor window. Then adjust the potentiometer so the value is right at the 400 threshold and make sure the LED is responding appropriately. Finally, we want to slow down the readings to add some stability. We do this with the delay() function. delay(1); // delay in between reads for stability 1 delay(1); // delay in between reads for stability Let’s recap. First we read the value at the analog pin and assign that value to a variable. Next we check if that variable is more than or less than our threshold value. If it is above the threshold the LED turns on, if it is below the threshold the LED turns off. We also want to see the actual values at the analog pin, so we print them to the serial monitor. Finally, we wait a millisecond before our next reading – which starts the loop() at the top. You can see how handy the if-else statement can be. As I have said previously, the if-else statement is a staple of programming – you will see it (or a similar form of it), in any programming language you encounter henceforth. Try On Your Own Challenges Adjust the value of the threshold variable. Write an additional if statement to turn on the LED when the analogValue variable is less than 100. The LED should turn on when analogValue is greater than 400 and less than 100. Further Reading If-Else Statement – From the Arduino Reference More on the If-Else statement – The example sketch on the Arduino Website
Let’s expand the repertoire of output that we can use by looking at the function analogWrite(). I experienced much confusion with analogWrite(), because I suspected that it had to do with the analog pins on the Arduino. The function, however, has nothing to do with the analog pins. There are 5 pins on most Arduino boards marked with ‘PWM’ next to the pin number (on some boards it is an “~” symbol) – these pins can be invoked to rapidly change the power being applied at the pin – this is a technique called pulse width modulation (PWM). If you like this tutorial, click here to check out FREE Video Arduino course – thousands of people have really enjoyed it. You Will Need LED – any color is fine 220 Ohm Resistor Alligator Clip Glacial ice cubes Step-by-Step Instructions Take the short leg of the LED and insert it in the GND pin. Take either leg of the resistor and place it in pin 9. Connect the long leg of the LED with the other leg of the resistor using an alligator clip Plug the Arduino into your computer with the USB cable Open up the Arduino IDE Open the sketch for this section. Click the Verify button (top left). The button will turn orange and then blue once finished. Click the Upload button. The button will turn orange and then blue when finished. Watch in mesmerizing amazement as the LED fades in and out. Arduino Fade an LED BoardThis image built with Fritzing. Discuss the Sketch Below is the sketch in its entirety from the Arduino IDE: /* Fade This example shows how to fade an LED on pin 9 using the analogWrite() function. This example code is in the public domain. */ int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by // the setup routine runs once when you press reset: void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // set the brightness of pin 9: analogWrite(led, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 /* Fade This example shows how to fade an LED on pin 9 using the analogWrite() function. This example code is in the public domain. */ int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by // the setup routine runs once when you press reset: void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } // the loop routine runs over and over again forever: void loop() { // set the brightness of pin 9: analogWrite(led, brightness); // change the brightness for next time through the loop: brightness = brightness + fadeAmount; // reverse the direction of the fading at the ends of the fade: if (brightness == 0 || brightness == 255) { fadeAmount = -fadeAmount ; } // wait for 30 milliseconds to see the dimming effect delay(30); } The sketch starts with the usual multiline comment describing the program and how to set up the circuit. The first block of code we encounter is the declaration and initialization of three integer variables. The variable names and comments are both descriptive and helpful – remember this when naming and commenting your own code – useful comments are a pillar of success! int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by 1 2 3 4 5 int led = 9; // the pin that the LED is attached to int brightness = 0; // how bright the LED is int fadeAmount = 5; // how many points to fade the LED by The brightness variable will store the value of the current brightness of the LED. fadeAmount is the rate at which the LED will fade and brighten. And of course, as the comments explain, led is simply the pin number where we have attached the LED (through a 220-ohm resistor). Now that we have declared and initialized our variables, we move on to setting up the board with the setup() function… void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } 1 2 3 4 5 6 7 void setup() { // declare pin 9 to be an output: pinMode(led, OUTPUT); } The only thing we do here is set the mode of pin 9 as an OUTPUT using the pinMode() function. Recall that pinMode() takes two arguments – the pin number and the mode. In this case, we assign the pin number using the variable led, which we previously initialized as the number 9. By now you know that setup() only runs once – the code inside the setup() curly bracket will only be executed a single time by the Arduino. Where the real action happens is in loop(). The first function we encounter in the loop() is analogWrite(). This function invokes the Pulse Width Modulation capabilities of the Arduino board. Pulse Width Modulation basically adjusts the power output at the pin. So you can have a lot of power or a little power applied at the pin, it’s your call, just tell the analogWrite() function which pin to modulate and how much power you want to be applied. The scale is from 0 to 255 with zero being the lowest power setting and 255 being the highest. For a discussion of what is actually happening with pulse width modulation check out the further reading section. As alluded to above, analogWrite() takes two arguments… analogWrite(pin, value); 1 analogWrite(pin, value); You can utilize analogWrite() with pins 3, 5, 6, 9, 10 and 11 – recall there is a “PWM” or “~” next to the pin number on the board. In this sketch we use the arguments: analogWrite(led, brightness); 1 analogWrite(led, brightness); The first thing we do in the loop is write a value to pin 9 (recall that led holds the number 9) where we have our LED attached (through a resistor) – and we set the value to 0 (zero is what our brightness variable initially holds). This will keep our LED dark to start with. Key Points about the analogWrite function The next line of code we encounter is: brightness = brightness + fadeAmount; ( 0 ) = ( 0 ) + (5)
In the last lesson you learned about using the analogRead() function to collect data from a sensor connected to one of the Arduino analog pins. The range of data we received from the analogRead() function was mapped between 0 to 1023. What if we want to know the actual voltage being applied at the pin? If you like this tutorial, click here to check out FREE Video Arduino course – thousands of people have really enjoyed it. You Will Need Potentiometer (any resistance range will work) Jumper Wires – at least 3 Persian Rug Step-by-Step Instructions Place the potentiometer into your breadboard. Run a jumper wire from the 5-Volt pin of the Arduino to either one of the outside pins of the potentiometer. Run another jumper wire from one of the ground pins on the Arduino (labeled GND) to the other outside pin of the potentiometer. Run the final jumper wire from pin A0 on the Arduino to the middle pin of the potentiometer. Plug the Arduino into your computer. Open up the Arduino IDE. Open the sketch for this section. Click the Verify button on the top left side of the screen. It will turn orange and then back to blue once it has finished. Click the Upload button (next to the Verify button). It will turn orange and then back to blue once it has finished. On the menu bar, go to Tools > Serial Monitor – this will open the Serial Monitor window – you should see numbers rolling down this screen. Now adjust the knob of your potentiometer and watch the serial monitor window, the numbers should adjust between 0 and 5. Adruino Board Set up For Switch Case This image crafted with Fritzing. The Arduino Code /* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */ // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(voltage); } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */ // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V): float voltage = sensorValue * (5.0 / 1023.0); // print out the value you read: Serial.println(voltage); } Discuss the Sketch This sketch does the exact same thing as the last lesson sketch except for one important change. It takes the reading provided by the analogRead() function and converts it into the actual voltage value at the respective analog pin. Let’s start from the top to review what is taking place. We have no variables to declare and initialize at the beginning of the sketch so we jump right into the setup() function. Inside the curly braces of setup() we begin serial communications by setting the baud rate. This is done using the function Serial.begin(9600). void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } 1 2 3 4 5 6 7 void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } That is all there is to the setup() of this sketch. The next block of code is loop(). Inside the curly braces of loop() the first thing we do is read the value at analog pin A0 and assign it to an integer variable called sensorValue. int sensorValue = analogRead(A0); 1 int sensorValue = analogRead(A0); Once we have recorded this value, we want to convert it to an actual voltage. You will recall that the range returned by the analogRead() function is between 0 and 1023. We want this to reflect the actual voltage at the pin – which is between 0 and 5 volts depending on where the potentiometer knob is turned. So let’s take a look at how we might accomplish this… Explanation of analog sensor code float voltage = sensorValue * (5.0 / 1023.0); 1 float voltage = sensorValue * (5.0 / 1023.0); The first thing we encounter is a new data type – called float. A float is simply a number with a decimal point; say for example 3.14 or 2.17781778. Floats, also called floating point numbers, can be huge in value, and take much more time for the Arduino to churn through than integers – this is why they are used only when necessary. We want the voltage variable set as a float data type because it will provide more resolution than an integer. The voltage variable is set equal to a somewhat confusing calculation. Our goal is to take the value that analogRead() returns and convert it into an actual voltage value. We use a conversion factor to accomplish this feat. By multiplying sensorValue by (5.0/1023.0), it scales down the range from 0-1023 (which is the range that analogRead() returns) to the range 0-5 which is the actual range of the voltage. You can think of the conversion calculation by saying “sensorValue is to X volts as 5 volts is to 1023”, where X is the converted voltage value we are trying to determine. Once we have this new value, it is assigned to the variable voltage – all of this on one line of code. Let’s recap the program… Read the sensor value at an analog pin. Assign this value to a variable. Convert this value to a voltage Save the voltage measurement to another variable And then… Well, we print it back to the serial monitor window so we can see what the voltage is at our pin. The loop() will start over again, it will sample a new value at the pin, it will convert that value and print it, and loop and loop and loop – you get the idea. Try On Your Own Switch from using the 5-volt pin on the Arduino to the 3.3-volt pin. Make sure to adjust the conversion factor. Instead of converting to a voltage value, can you change the conversion factor to return a range from 0 to 100? Further Reading float map() – this function takes the work out of conversion factors – can you implement it here?
Knowing if something is on or off can be extremely useful, but often you will want to know more. How bright is the light? How fast is the satellite moving? These types of answers are often analog – they cover a large range of values, not just on or off. The Arduino handles analog inputs with 6 dedicated pins, labeled A0 through A5. These pins have access to an analog-to-digital converter, which takes the range of input values and creates a digital version by cutting up the range into tiny pieces. All this is handled behind the scenes – all you have to do is use some very simple functions and you will get what you need. You Will Need Potentiometer (any resistance range will work) Jumper Wires – at least 3 Bicycle tire Step-by-Step Instructions Place the potentiometer into your breadboard. Run a jumper wire from the 5-Volt pin of the Arduino to either one of the outside pins of your potentiometer. Run another jumper wire from one of the ground pins on your Arduino (labeled GND) to the other outside pin of the potentiometer. Run the final jumper wire from pin A0 on your Arduino to the middle pin of the potentiometer. Plug the Arduino into your computer. Open up the Arduino IDE. Open the sketch for this section. Click the Verify button on the top left side of the screen. It will turn orange and then back to blue once it has finished. Click the Upload button (next to the Verify button). It will turn orange and then back to blue once it has finished. On the menu bar, go to Tools > Serial Monitor – this will open the Serial Monitor window – you should see numbers rolling down this screen. Now adjust the knob of the potentiometer and watch the serial monitor window. The numbers should adjust between 0 and 1023. Using the Arduino analogread and map function with a potentiometer at pin A0 This image composed with Fritzing. The Arduino Code /* AnalogReadSerial Reads an analog input on pin 0, prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */ // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); delay(1); // delay in between reads for stability } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 /* AnalogReadSerial Reads an analog input on pin 0, prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground. This example code is in the public domain. */ // the setup routine runs once when you press reset: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } // the loop routine runs over and over again forever: void loop() { // read the input on analog pin 0: int sensorValue = analogRead(A0); // print out the value you read: Serial.println(sensorValue); delay(1); // delay in between reads for stability } Discuss the Sketch This sketch starts with a multi-line comment describing the sketch and the circuit. You will probably notice that the first block of code is the setup() function – we do not declare or initialize any variables at the beginning of this sketch – instead we will do this inside the loop() function, as in the last example. Inside the curly braces of setup() we revisit the Serial library and use the function Serial.begin(). void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } 1 2 3 4 5 6 7 void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); } If you recall from the last lesson, Serial.begin() takes the baud rate as an argument (this will almost always be 9600). This function allows you to setup a communication channel between the computer and the Arduino. As you may know by now, setup() only runs once, and then we move on to the next block of code. But wait! Don’t we have to set the mode of the pin we will be using? Great point! What the Arduino does, by default, is set all the pins on the board as INPUTs unless you tell it otherwise. So in many cases, you do not have to explicitly set a pin as an input using the pinMode() function. That being said – I make it a habit to do this anyway – because it makes things clear to me – and that is worth it in space and effort. So I dare you, set the mode of the pin using the pinMode(A0, INPUT) function inside the curly braces of setup()– you won’t regret it. Moving on to the loop() function, we start with a variable declaration and initialization. int sensorValue = analogRead(A0); 1 int sensorValue = analogRead(A0); We declare a variable called sensorValue and we initialize it to the output of a new function. This new function is the glamorous analogRead(). So take a wild guess what this new function analogRead() does. It reads the value at the analog pin that you have chosen – in this case, it is the analog pin A0, where we have the center pin of the potentiometer connected. The voltage at pin A0 will be mapped to a number between 0 and 1023, and this value will be assigned to the variable sensorValue. If you recall from above, the actual voltage at pin A0 will be between 0 and 5 volts, depending on where your potentiometer is adjusted – this value gets mapped to the range 0 – 1023 with the help of the analog-to-digital converter. So we have a variable that has recorded the value at our potentiometer – what next? Well, let’s look at the value. To do that, we need to print it from the Arduino to our computer – and you guessed it, we will use the Serial library function println() to do just that… Serial.println(sensorValue); 1 Serial.println(sensorValue); No big surprises here – we send as an argument the sensorValue variable to the function Serial.println() and our serial monitor window will display the resulting values. To finish the sketch, we invoke the delay() function for one millisecond to make sure our next reading is a stable one and we start at the top of the loop() again. We record a new value using analogRead(), save it to the variable sensorValue and then print it to the computer. All this is good and well, you might be thinking, but what does a potentiometer have to do with sensors? A potentiometer doesn’t sense anything! You are right – but interestingly, many sensors work by applying the same principle that a potentiometer does – adjusting resistance. Take a photo-resister for example – it can be used to sense light – because the resistance changes based on the brightness of light that it is exposed to – this change in resistance will adjust the amount of voltage that a pin on the receiving end will receive. So now the ball is in your court – what can you use analogRead() for? Try On Your Own Change the analog pin to A2. Make adjustments in the code and the circuit. Try a different potentiometer in the circuit, does it affect the range of values displayed? Further Reading analogRead() Analog Input Pins potentiometer tutorial – this is good
As simple as it may seem, knowing when something is either on or off can be a great tool for designing something useful. This lesson will answer the following questions: Is a button being pressed? Has a switch been turned on? What is the on/off sensor status? When you can answer questions like these, you can implement actions based on the current status – if the button is pressed do this – otherwise, do that. If the sensor is HIGH take this action, otherwise do nothing. You get the gist. But before we can implement the actions, we have to be able to track the status and the changes of the digital pins. If you like this tutorial, click here to check out FREE Video Arduino course – thousands of people have really enjoyed it. You Will Need A momentary push button – this is a button that is spring-loaded, i.e. it never stays in a down position unless it’s held down. Jumper wires (3) A 10,000 Ohm resistor more commonly referred to as a 10K resistor A very ripe banana, (1) – not completely useful, but nutritious Step-by-Step Instructions Connect the pushbutton to the breadboard. Connect one side of the pushbutton to the 5-volt pin on the Arduino board using a jumper wire. Connect one side of the 10K resistor to the other side of the pushbutton. Connect the other side of the resistor to the ground pin on the Arduino. You may have to use a jumper wire to make it reach. On the same side, the resistor is connected to the pushbutton, connect a jumper wire and run it to pin 2 on the Arduino board. Connect the Arduino to your computer with the USB cable. Open the sketch for this section. Click the Verify button in the top left corner of the IDE. The Verify button will turn orange and then back to blue when it has completed compiling. Click the Upload Button (located to the immediate right of the Verify button). This button will also turn orange and then back to blue once the sketch is uploaded to the Arduino board. Now go to the menu bar at the top and select Tools > Serial Monitor. Or you could use the shortcut key, Shift + Control + M. The serial monitor window will open and will be spouting off numbers. It should be a bunch of zeros. Press and hold the pushbutton – watch the serial monitor window, the numbers should now be ones. If the numbers are not scrolling, make sure you click Autoscroll at the bottom left of the serial monitor window. digitalRead Serial Port Circuit This image built with Fritzing. The Arduino Code /* DigitalReadSerial Reads a digital input on pin 2, prints the result to the serial monitor This example code is in the public domain. */ // digital pin 2 has a pushbutton attached to it. Give it a name: int pushButton = 2; // the setup routine runs once: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); // make the pushbutton’s pin an input: pinMode(pushButton, INPUT); } // the loop routine runs over and over again forever: void loop() { // read the input pin: int buttonState = digitalRead(pushButton); // print out the state of the button: Serial.println(buttonState); delay(1); // delay in between reads for stability } 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 /* DigitalReadSerial Reads a digital input on pin 2, prints the result to the serial monitor This example code is in the public domain. */ // digital pin 2 has a pushbutton attached to it. Give it a name: int pushButton = 2; // the setup routine runs once: void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); // make the pushbutton’s pin an input: pinMode(pushButton, INPUT); } // the loop routine runs over and over again forever: void loop() { // read the input pin: int buttonState = digitalRead(pushButton); // print out the state of the button: Serial.println(buttonState); delay(1); // delay in between reads for stability } Discuss the Sketch This sketch opens with a multi-line comment containing a short description of the program and circuit. The first block of code following the comment is where we declare and initialize variables. From the last lesson, we are familiar with the integer data type. int pushButton = 2; //This is the pin that our push button is connected to. 1 int pushButton = 2; //This is the pin that our push button is connected to. Notice how the variable pushButton is declared and initialized all on the same line. Also, notice the descriptive name of the variable – pushButton – the variable name implies its use within the program – this is a good example to follow. Let’s consider what we have done so far – we have made a variable that will store the pin number that our pushbutton is connected to. The next block of code we come to is the setup(). Inside these wily curly brackets there are two functions – a familiar one, pinMode() and another which we will learn to love – Serial.begin(). Serial.begin() is part of a family of functions referred to as a library. The name of the library is the Serial library. A library is just a group of functions that work toward a similar purpose. If you had a Circus library, it might contain the functions juggle(), balance() and flamingCircleOfDeath(). To access the functions in a library, you write the name of the library followed by the name of the function in the library, with a period in between. Circus.juggle(); 1 Circus.juggle(); Arduino has many preinstalled libraries. There are also many community-contributed libraries that you can add. You can view all of the preinstalled libraries and some of the contributed libraries at http://arduino.cc/en/Reference/Libraries. So what does the Serial library do? The Serial library helps establish communication between your computer and the Arduino board. If you ever go to marriage counseling, you will learn that communication involves sending and receiving. Data can flow both ways. If we want to establish this communication, we use the begin() function from the Serial library. Serial.begin(9600); 1 Serial.begin(9600); The begin() function takes one argument – the baud rate. What is the baud rate you ask? It is the rate at which data will flow between your computer and the Arduino. For most Arduino sketches a baud rate of 9600 is used as the argument. That’s all you really need to know about the baud rate to get started with serial monitoring. But I have a feeling you want to know more, so if you check out the further reading section at the end of this tutorial, there will be some links to tempt your insatiable desire for acquiring an understanding of all things in the universe. The next function after Serial.begin() is the pinMode() function. We want to set the mode of a pin and what is cool about pinMode() this time around is that we are changing the arguments we pass to the function. Instead of being an OUTPUT (as in the Blink sketch), we want our pin to be an INPUT because we want to read voltage at this pin, not provide it. pinMode(pushButton, INPUT) ; 1 pinMode(pushButton, INPUT) ; Here we use the variable pushButton to let the function know we are setting the mode at pin 2. Then we use the keyword INPUT, to say which mode we want. Those are the only two functions in the setup() curly braces – and just as a reminder – setup() only runs once. The next block of code is the function loop(). What do we see inside the curly braces of the loop()? int buttonState = digitalRead(pushButton); 1 int buttonState = digitalRead(pushButton); Whoa! What the heck is this? It looks like the programmer is declaring a variable! I thought variables were declared at the top of the sketch. While variables are often declared before the setup() function, you can actually declare and initialize a variable just about anywhere in a sketch. Soon you will see why this placement is the way to go. Let’s break down this statement. First, look at the data type and the name. We declare an integer and name it buttonState. Notice the variable name buttonState is indicative of its purpose, as we will see this variable is assigned the position of the button. To initialize the variable, we see something altogether new – the variable is set equal to the output of a function called digitalRead(). This is going to take a little recall power on your part. Do you remember the reason for the word void in front of the loop() function? We had to write void because the function loop() does not return a value. But that is not the case for the function digitalRead(). The digitalRead() function returns an integer – either 1 or 0. This value is then assigned to the variable buttonState. If it is 1, the voltage at the pin is HIGH, if the value is 0, the voltage at the pin is LOW. What pin you ask? Well the pin you pass as an argument in the digitalRead() function. In this case, we send the variable pushButton, because we want to read the state of pin 2 (if you recall pushButton was initialized to equal 2). All of this is in the following line of code: int buttonState = digitalRead(pushButton); 1 int buttonState = digitalRead(pushButton); This is why Arduino rocks – one line of code and you are on your way to dominating the world. Now the state of our pushbutton will be either HIGH (pressed) or LOW (not-pressed). HIGH will be reported as a 1, and LOW will be reported as 0. When we press the pushbutton, pin 2 is exposed to the 5-volts from the Arduino board, this is considered HIGH, and the digitalRead() function will return 1. If the button is not pressed, then all that pin 2 is exposed to is the ground voltage which is 0 and digitalRead() will return 0. Explanation of Digital Read Code In the next line of code we return to the Serial library for another function called println(). Serial.println(buttonState); 1 Serial.println(buttonState); The Serial.println() function returns the value of whatever variable you stick in as an argument. It will report this value to the serial monitor window on your Arduino IDE. To open up the serial monitor window all you have to do is click Tools > Serial Monitor (or SHIFT + CONTROL + M). This is one way to retrieve the data on your Arduino board. Keep in mind, that when you unplug your Arduino and use some batteries to charge it, the Serial.println() function won’t do you much good. But while you are creating the circuit and the sketch, there is no better way to troubleshoot than use the println() and print() functions from the Serial library. So let’s cover what we have done so far in the loop. First we read the state of digital pin 2 and save the state in a variable. Then we display the state in the serial monitor window. Finally, we use the delay() function and wait one millisecond – this allows the reading at the pin to stabilize. Once this is done, the loop starts from the top. We read another value at pin 2 – we are checking every time whether the button is pressed or not pressed – this value gets assigned to our buttonState variable, then we display the newly recorded value to serial monitor window – again. And we do this over and over – hundreds of times per second. So go ahead, press that button, watch the serial monitor window – I think you are already brewing applications for these functions… Try On Your Own Challenge Change the function Serial.println() to Serial.print(). What happens to the output in the serial monitor window? Can you tell the difference between the two functions? Change the pin that you are reading to pin 3. Make the circuit change and the changes to the sketch. Further Reading Baud Rate Serial Library Serial.begin() Serial.println() Serial.print()
The first program you usually write when learning a new programming language is called, “Hello World”. Its only function is to display the words “Hello World” on the computer monitor. When learning to program microcontrollers such as the Arduino, the equivalent of “Hello World” is a program that blinks an LED. Guess what it is called – Blink. You Will Need An LED (any color works fine) A 220 Ohm Resistor An alligator clip (not essential but makes the circuit easier) Fourteen small and smooth rocks from the a western pacific island (not essential but adds an esoteric feel) NOTE: On most Arduino boards there is an LED soldered right by pin 13 – it is actually connected to pin 13 – so if you do not have an LED laying around (or a resistor for that matter), you can use the board mounted LED – it will blink with the same sketch. Step-by-Step Instructions Insert the short leg of the LED into the GND pin on your Arduino (use the GND pin closest to pin 13). Connect the 220 Ohm resistor to pin 13 on the Arduino. It doesn’t matter which way you connect the resistor. Use the alligator clip to connect the long leg of the LED to the other leg of the resistor. If you do not have an alligator clip, twist the two leads together as best you can to get a steady electrical connection. Plug the Arduino board into your computer with a USB cable. Open up the Arduino IDE. Open the sketch for this section. Click the Verify button on the top left. It should turn orange and then back to blue. Click the Upload button. It will also turn orange and then blue once the sketch has finished uploading to your Arduino board. Now monitor the Arduino board – the LED should be blinking. This image was made using Fritzing. The Arduino Code 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 /* Blink Turns on an LED on for one second, then off for one second, repeatedly. Most Arduinos have an on-board LED you can control. On the Uno and Leonardo, it is attached to digital pin 13. If you're unsure what pin the on-board LED is connected to on your Arduino model, check the documentation at http://www.arduino.cc This example code is in the public domain. modified 8 May 2014 by Scott Fitzgerald */ // the setup function runs once when you press reset or power the board void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); } // the loop function runs over and over again forever void loop() { digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } Discuss the Sketch On the previous page, you can see the Arduino code that constitutes the Blink program – make sure to read each line, even if doesn’t make any sense yet. Notice the comments at the top of the program. Note the use of the multi-line comments syntax /* */. It is always a good idea to take time and see what the programmer has to say about the sketch they wrote. The comments will likely be concise, describing how the program works or what it should accomplish. A few may even tell you how to connect the circuit. The next block of code you encounter in the Blink sketch is… 1 2 3 4 void setup( ) { // initialize the digital pin as an output. pinMode(led, OUTPUT); } Recall that the setup() function is in almost every Arduino sketch you encounter. Inside the curly braces is code that will only be run once by the Arduino. For this sketch notice the function pinMode() is inside the curly braces of the setup() function. Let me start by saying that pinMode() is a wonderful function. If you recall, functions can take arguments. The pinMode() function takes two arguments – it wants a pin number and a mode for that pin. The pin number is easy, 0 to 13 for digital pins, and A0 to A5 for analog pins. The mode is an easy designation as well, you want the pin to be either an INPUT (good for reading a sensor) or an OUTPUT (good for powering an LED). When a pin is set as an INPUT, it prepares the pin to read voltages that will be applied at the pin. When a pin is set as an OUTPUT, it prepares the pin to output voltage – more on this later. In this example, we want to light an LED, this requires that voltage is applied at pin 13. Therefore, we need the mode of pin 13 set as an OUTPUT. Keep in mind that setting the mode of the pin to OUTPUT does not apply a voltage, it enables the pin to supply a voltage once it is programmed to do so. Moving on to the final block of code, we come to our favorite and ubiquitous function void loop()… 1 2 3 4 5 6 void loop( ) { digitalWrite(led,HIGH);// turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(led,LOW); // turn the LED off by making the voltage LOW delay(1000); // wait for a second } You may recall that void loop() runs over and over again. In this loop, we see two functions: digitalWrite() and delay(). The function digitalWrite() is used to apply either HIGH or LOW voltage to a pin. HIGH will apply 5 volts to the pin you designate and LOW will apply 0 volts. If you apply 5 volts to a pin that is connected through an LED to ground, then the LED will light up. There is a voltage difference between the pin and ground, thus current is able to flow through the LED. If you apply 0 volts to the same pin the LED will not light up because no current is being “pushed” through the circuit – the voltage at ground and at the pin are both zero. 1 2 digitalWrite() takes two arguments, the pin number and the level of voltage, either HIGH or LOW, as we have discussed above. digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level) We want to start the loop by applying HIGH voltage to pin 13, where our LED is attached. In the digitalWrite() function we use the variable name ‘led’ to refer back to the value 13 – which was previously assigned. Notice that there is no need to explicitly write 13 in the digitalWrite() function, instead we are able to use the variable ‘led’. Variables are awesome like that – they can take the place of numbers and are much easier to change and track. Every time we use the ‘led’ variable, the Arduino will see 13. If we later decide to move our LED to pin 10, then all we have to do is change the value of ‘led’ once, and all the instances of ‘led’ are changed too. Once digitalWrite() function has been executed, the LED will get bright – we just applied 5 volts, so hey, that makes sense. The next thing we do is delay the Arduino sketch to enjoy the bright glow of our LED. To do this, we use the delay() function. The delay() function takes one argument – the number of milliseconds you want the program to delay. In this case, we want 1000 milliseconds, which equals one second. First we said, “apply high voltage” and now we say – wait one second. Our LED will glow for exactly one second. But that gets old, and we have to stay true to the name of the sketch, so next we tell the Arduino to write a LOW voltage to pin 13 – to do this we use the same function as before, namely digitalWrite(), but, this time, we want LOW voltage instead of HIGH. Now the LED goes dark because no current is flowing. In order to sustain that darkness we use the delay() function again for one second. Now the LED is dark for one second. We are at the end of the loop. We turned the LED on for a second, then we turned it off for a second – what next? Once the Arduino completes the loop, it starts at the top of the loop again and repeats like a broken record. Once again, the LED will light up, delay a second and then go dark for one second. And repeat – now you have a blinking LED – pretty cool for just a couple lines of code! Try on Your Own Challenge Change the value of the delay functions. What happens? Change the number of the led variable to 12 and move the long leg of your LED to pin 12. See what happens. Further Reading int pinMode() digitalWrite() delay()
More Than Just Code podcast - iOS and Swift development, news and advice
We start off talking about innovations in integrated circuitry. Also discussed is the latest betas for iOS, OS X and Xcode as well as Apple's iCloud distribution among online services. Aaron posts Rene Richie's piece on App Store vs indie devs. Job opportunities and employment recruiters are discussed. We're getting ready with a WWDC Wishlist as well as the Apple Special Event. A Swift method naming convention change proposal is accepted. Picks: 123D Circuits, Miracle Timer, Cobalt & Factor Samurai Episode 83 Show Notes: Apple releases OS X 10.11.4 beta 7 with Messages & Notes improvements, more Google Inks Cloud Computing Services Deal With Apple IBM Bluemix What no indie developer wants to hear about the App Store Magpie for Apple TV Anvil TACOW Mark Pavlidis Shopifiy Careers WWDC Wishlist UXKit Apple Special Event: March 21, 2016 RWDevCon 2016 Post-Mortem Establish consistent label behavior across all parameters including first labels Fritzing.org Episode 83 Picks: 123D Circuits How to pass a programming interview Miracle Timer Cabalot Factor Samurai - Multiply and Divide your way to Times Tables Mastery
Hasta ahora siempre hemos hablado de prototipado. Pero llega un momento en que queremos dar un paso más y queremos realizar un producto final. En este capitulo os vamos a contar las herramientas para Makers que tenemos disponibles. Con ellas nos convertiremos en profesionales de este mundo y llegaremos a convertir nuestra idea en un producto final preparado para comercializarlo o utilizarlo en su emplazamiento definitivo.Pero antes de empezar queremos darle las gracias a Gabriel Viso por dejarnos estar en su programa y por tener una charla tan amena en su podcast pitando. Si quieres escuchar la charla que tuvimos puedes hacerlo desde aquí. No os la podéis perder, hablamos de Arduino y del proyecto que estamos hablando y también damos nuestras impresiones sobre estas materias y la educación en España.Queremos recordaros, que un par de semanas cumplimos nuestro primer año publicando este podcast y queremos celebrarlo con todos vosotros. Nos podéis enviar mensajes diciéndonos que es lo que más os gusta y lo que menos del programa, si añadiríais alguna sección, si echáis en falta algún tema... en definitiva lo que queráis decirnos y en ese programa lo veremos. También nos podéis enviar mensajes de audio con algún mensaje para la comunidad o para nosotros, recordad presentaros en el audio.Y como siempre, para contactar con nosotros y enviarnos cuanlquier mensaje, duda o sugerencia lo puedes hacer de diferentes maneras, a través del formulario de contacto, en el e-mail info@programarfacil.com, en Twitter (@programarfacilc) o en Facebook. También puedes mantenerte al día a través de la lista de distribución.Y vamos en materia con el programa. La finalidad de este capítulo es ver los pasos que queremos seguir y las herramientas que necesitamos para crear un proyecto de principio a fin. Vamos a dividir el capítulo en 4 secciones:Análisis y prototipado.Fabricación PCB.Diseño chasis o carcasas.Fabricación chasis.Pero lo primero es decidir que proyecto queremos hacer y su finalidad. Los ejemplos clásicos son:Estación meteorológica.Medidor de contaminación.Sistema domótico.Brazo robótico.Análisis y prototipadoEn esta fase que a su vez la podemos dividir en dos. Lo primero es coger "papel y boli" y ver las necesidades que vamos a tener, los componentes que vamos a necesitar, las herramientas que vamos a utilizar y la lógica del programa que queremos implementar. Y comenzaremos a prototipar realizando pruebas de circuitos y de programación para ver si realmente nuestro proyecto cumple la finalidad que le hemos propuesto. Veamoslo todo detenidamente.Elección de hardware:En esta fase inicial escogeremos una placa de Arduino UNO, Mega o 101. En un paso posterior ya sabremos que placa se ajusta más a nuestras necesidades y elegiremos la definitiva. En este punto también deberemos ver que componentes vamos a necesitar y las herramientas como mutímetro, alicates, etc... vamos a utilizar. En el capitulo "kit de iniciación" hablamos de todas estas herramientas.Elección de software:Esta elección es bastante personal, ya que a cada uno nos sentimos más cómodos con un IDE que con otro. Pero siempre hay que mirar las caracteristicas que tienen unos y otros y nuestras necesidades ya que no siempre el IDE va a cumplir nuestras necesidades. Por ejemplo, los lenguajes visuales no son adecuados para este tipo de proyecto, ya que estan limitados y solo son una elección a la hora de aprender a programar, no de utilizarlos profesionalmente.También deberemos ver si tenemos conexión a internet o no para elegir un IDE online o uno de escritorio o si el IDE tiene alguna caracteristica imprescindible para nuestro proyecto. De esto hemos hablado largo y tendido en el capitulo dedicado a los entorno de desarrollo para Arduino pero aqui os dejamos un listado de los más interesantes:Arduino IDE oficialArduino Create (online)Codebender (online)Visual Micro (Visual Studio)Atmel Studio 7Elección de visualización de datos:No es lo mismo visualizar los datos en una pantalla TFT o LCD, que en un web, en un móvil o en una app de escritorio. Esta elección nos cambiara por completo el proyecto, la conexión que tendremos con otro hardware y por lo tanto la lógica de nuestro programa.Almacenamiento de datos, computación en la nube:Es posible que nos interese almacenar nuestros datos en la nube para que estén accesibles a otro dispositivo utilizando servicios web. A continuación os listamos algunos de los servicios más recomendables:AzureAWS Amazon CloudApp Engine de GoogleOracleBluemixY uno especializado en el IoT que ya hablamos de él:XivelyDiseño del prototipo del circuito:Entramos en la fase de prototipar el circuito, para ellos tenemos dos herramientas que os hemos hablado en muchas ocasiones:123dcircuits:No es software librePermite simulación.Faltan componentesNo están todas las placas de ArduinoNo permite subir a la placaFritzing:Software libreNo permite simulaciónGran cantidad de componentesPosibilidad de importar componentesBastantes tipos de ArduinoPermite cargar en la placaFabricación de circuito impreso (PCB)Ya tenemos el prototipo ahora hay que construirlo. Dependemos de los objetivos y requerimientos no es lo mismo si vamos a necesitar comunicación con otro dispositivo, con internet o cuando pines digitales y analógicos vamos a necesitar. También debemos tener en cuenta que consumo tiene nuestro circuito, que batería debemos incorporar o las condiciones en la que se va a encontrar, si en la intemperie o dentro de una casa.Con toda esta información vamos a elegir la placa final que vamos a elegir. Empezamos con un Arduino UNO o MEGA, pero estas son muy grandes y puede que no necesitemos tanta potencia o tantos pines. Lo recomendable es escoger una de las siguientes:PlacaArduinoMicroArduinoPro MiniArduinoProArduinoMKR1000Voltaje Operación5V3.3V y 5V3.3V y 5V3.3 VPines digitales2014148PWM7664Pines analógicos12667Conexión-- WIFIY si es por tamaño tenemos las llamadas placas Wearables que aunque estan pensadas para textil nada nos impide utilizarlas en otros proyectos. Estas placas que son circulares tienen un diámetro de 2.7 cm.PlacaArduino GemaArduino LilypadVoltaje Operación3.3 V2.7 V y 5.5 VPines digitales39PWM25Pines analógicos14En cuanto a los componentes tendremos que fijarnos en el consumo, en la precisión que tienen y en el rango de operaciones (temperatura, tensión e intensidad).Diseño del circuito impresoUna vez tenemos claro todos los componentes y realizado el prototipado es hora de construir el PCB (Printed Circuit Board), el circuito impreso. Lo que hacemos es pasar nuestro circuito a una placa o tarjeta eliminando los cables y utilizando pistas de material conductor, normalmente cobre. Y ya iremos dando forma a nuestro producto final.Para realizar esto, podemos utilizar el programa Fritzing, ahí podemos diseñar nuestro diseño PCB y luego este programa nos da la facilidad de enviar este circuito y pedirlo online para que nos produzcan nuestras placas a la que tendremos que soldar nuestros componentes.Diseño de chasis o carcasasY ya solo nos falta aportarle a nuestro producto un chasis o una carcasas, como os hemos dicho antes no es lo mismo si el producto va a estar en la intemperie o en un sitio cerrado. Existe multitud de software para diseño 3D y desde aquí os recomendamos unos cuantos:Software libreFreeCADBlender (animación y modelado 3D)Google SketchUp (Tiene base de datos de modelos 3D sobre todo para construcción)Software de pagoInventor (Autodesk)Autocad (Autodesk)Fusion 360 (Autodesk)SolidworksRhinoceros (Arquitectura)3D Studio (animación profesional)Pero también tenemos la opcion de ir a una base de datos de modelos 3D y escoger uno que se adapte a nuestro prototipo:Una de las más famosas Thingiverser (gracias a Cesar de La Hora Maker)YeggiCG traderGrab CAD3D Content CentralFabricación chasisY ya solo nos queda fabricar ese chasis y ¿dónde podemos fabricarlo?. Pues es recomendable buscar un Fablab en tu ciudad, si buscas en google seguro que encontraras uno cercano, normalmente están vinculados a las universidades como es el caso de Alicante. Y sino tienes uno cerca seguro que tienes una empresa de 3D cerca. Y bueno, siempre nos quedara la opción clásica, por corte láser o fresado.El recurso del diaElectroDroides una aplicación para Android con múltiples herramientas electrónicas y documentación técnica. La aplicación incluye entre otras herramientas: decodificador para el código de resistencias, calculadora de la ley de Ohm, calculadora de reactancia, divisor de voltaje o calculadora de vida de baterías. Una herramienta indispensable que te hará más fácil prototipar tu proyecto.Muchas gracias a todos por los comentarios y valoraciones que nos hacéis eniVoox, iTunes y en Spreaker, nos dan mucho ánimo para seguir con este proyecto.
Hoy vamos con un tema donde no vamos a ver nada de programación pero que es fundamental para aquellos que os queráis adentrar en el mundo Arduino, conceptos básicos de electrónica. Repasaremos que son las magnitudes, la electricidad y la electrónica. También os explicamos las leyes de Ohm y Kirchhoff.Si tenéis alguna duda sobre este tema o cualquier otro relacionado con la tecnología podéis mandarlas a través del formulario de contacto, a través de Twitter o por Facebook. Si queréis manteneros al día de las últimas novedades en la web os podéis suscribir a la lista de distribución.Las magnitudes físicas nos ayudan a medir y comparar el entorno en que vivimos. En Arduino también podemos medir nuestro entorno a través de sensores. Esto nos dará dos tipos de información, por un lado la cantidad con respecto a un estándar y por otro, poder predecir como va a evolucionar esa medida en un futuro. Si lo trasladamos al medidor de PH que estamos desarrollando, queremos obtener la cantidad de PH y evaluar en el tiempo para predecir futuros valores.Por otro lado, el Arduino está compuesto de circuitos eléctricos. Esto hace que sea fundamental tener ciertos conocimientos de electrónica y electricidad. Si ya has trasteado con un Arduino sabrás de qué hablamos, aquellos que todavía no lo hayáis hecho tarde o temprano os plantearéis que resistencia debo poner en un sitio o en otro. Está claro que muchas veces encuentras un esquema de un circuito montado y solo tienes que copiar, pero en algún momento te enfrentarás a algún obstáculo en el camino que, simplemente con conocer una fórmula (Ley Ohm), podrás resolverlo. Por eso hablamos de las siguientes leyes:Ley de OhmLeyes de KirchhoffSi quieres profundizar más en el tema puedes leer estos artículos relacionados:Introducción a la electrónicaResistencia pull-up y pull-downBreve introducción a ArduinoRecurso del díaFritzingOs presentamos Fritzing, una plataforma de software que nos permite diseñar y crear proyectos basados en Arduino u otras plataformas similares. Con este software seremos capaces de diseñar un PCB (circuito impreso) a partir de un diseño en una protoboard y poder crear dicho circuito mediante una empresa especializada. Es muy recomendable para documentar, controlar y diseñar nuestros proyectos con Arduino.Muchas gracias a todos por los comentarios y valoraciones que nos hacéis en iVoox, iTunes, Spreaker y Overcast nos dan mucho ánimo para seguir con este proyecto.
Fritzing est un logiciel permettant de réaliser des schémas électroniques de manière très simple, via une interface graphique. La vue platine d’essai est en particulier la plus intéressante pour les enseignants, car elle permet de montrer l’implantation des composants aux élèves. Si la plupart des modules Arduino sont directement inclus dans la base de composants, […]
Subscribe! is back after a long mid-year (summer-) break and with a new series.Starting with this episode, I'm going to explore a range of embedded systems prototyping platforms and, ultimately, how to connect tiny devices into the cloud for fun, scale, and security. We'll explore how to establish basic connectivity, discuss security options, talk about how to flow and handle telemetry data and how to do remote switching like turning a motor or switching a light from the cloud and do that in a way that it would scale to very, very many devices and poor connectivity conditions.Prototyping platforms allow hobbyists, researchers, and industrial design engineers to explore designs, and wire up and easily program special-purpose devices without soldering or even having to make a printed circuit. Once the design is stable, the prototype can then be turned into an actual device that can be produced at scale.In today's episode I'm going to give an overview of the prototyping platforms I'm going to explore in the upcoming few weeks. I'm initially going to focus on platforms that are cheap to buy and have existing communities, so that you can play along if you like: Arduino, Gadgeteer, Netduino, Android ADK, Seeedstudio Grove, and Raspberry Pi. Later this year, we'll also take a look at prototyping/evaluation platforms for industrial microcontrollers.Today and in the next few episodes, I'll be starting with the Arduino Ethernet board, which I bought as part of a Fritzing Starter Kit. Fritzing.org is an open-source hardware design initiative by the Interaction Design Lab at the University of Applied Sciences in Potsdam, Germany. [Go to Part 2 or Part 3 or Part 4 or Part 5]
Subscribe! is back after a long mid-year (summer-) break and with a new series.Starting with this episode, I'm going to explore a range of embedded systems prototyping platforms and, ultimately, how to connect tiny devices into the cloud for fun, scale, and security. We'll explore how to establish basic connectivity, discuss security options, talk about how to flow and handle telemetry data and how to do remote switching like turning a motor or switching a light from the cloud and do that in a way that it would scale to very, very many devices and poor connectivity conditions.Prototyping platforms allow hobbyists, researchers, and industrial design engineers to explore designs, and wire up and easily program special-purpose devices without soldering or even having to make a printed circuit. Once the design is stable, the prototype can then be turned into an actual device that can be produced at scale.In today's episode I'm going to give an overview of the prototyping platforms I'm going to explore in the upcoming few weeks. I'm initially going to focus on platforms that are cheap to buy and have existing communities, so that you can play along if you like: Arduino, Gadgeteer, Netduino, Android ADK, Seeedstudio Grove, and Raspberry Pi. Later this year, we'll also take a look at prototyping/evaluation platforms for industrial microcontrollers.Today and in the next few episodes, I'll be starting with the Arduino Ethernet board, which I bought as part of a Fritzing Starter Kit. Fritzing.org is an open-source hardware design initiative by the Interaction Design Lab at the University of Applied Sciences in Potsdam, Germany. [Go to Part 2 or Part 3 or Part 4 or Part 5]
Embedded Linux Conference Europe (ELC-E) 2012 wrapped up last week in Barcelona. By far, the most popular embedded platform of choice for demonstrations was BeagleBone. Here are four examples that include links to the slides taken from the eLinux wiki ELC-E presentation page. Videos of the presentations should be available from Free Electrons soon.Matt Ranostay opened up the presentations with "Beaglebone: The Perfect Telemetry Platform?" where he explored various telemetry applications such as weather stations, radiation monitors, earthquake detection mesh networks, home security systems and entropy pool generation. He discussed sharing data with tools like COSM and the hardware and software he developed for his own Geiger Cape plug-in board. Alan Ott of Signal 11 Software followed up with an excellent overview of "Wireless Networking with IEEE 802.15.4 and 6LoWPAN". Alan discussed the power consumption of various wireless communications technologies, security and much more, including what is supported in Linux. Alan wrapped up with a demo using BeagleBone and an ultrasonic range finder. Dave Anders snapped a picture of the Altoids-tin encased demo. Matt Porter of Texas Instruments stepped away from sensors and controls bringing back the Commodore 64 demoscene with "What's Old Is New: A 6502-based Remote Processor". While this might seem like a bit of a throw-back, many modern issues and solutions were explored to give us this taste of the past, including the Linux remoteproc/virtio interfaces to remote processors, the AM335x PRUSS processor that is extremely adept at bit-banging and the Fritzing design tool. Matt has also shared a picture of his wiring handy-work.Finally, Koen Kooi of CircuitCo presented on one of the fundamental BeagleBone challenges, "Supporting 200 Different Expansionboards: The Broken Promise of Devicetree". If you frequent #beagle, you probably already know that Koen isn't easy to please and so the title shouldn't be much of a surprise. You might then be surprised to note on the first slide where "broken" has been scratched out! We certainly aren't there yet, but the device tree maintainers and AM335x kernel developers are starting to address the unique opportunities around BeagleBone cape expansion boards in the mainline Linux kernel, making a reality out of the dream of supporting hundreds of boards with a single kernel distributed ahead of the add-ons!The continued enthusiasm of the embedded Linux community is just one element of what makes BeagleBoard.org successful, but it probably makes me happier than any other. With many of these developers moving the state of the Linux kernel ahead and even looking at sharing their hardware ideas in the BeagleBone Cape Plug-in Board Design Contest, I see a bright future where the largest collaborative software project of all time fully embraces the hardware and maker communities such that we can build a world where individuals and even children can reproduce electronics and computers down to the circuit level, not simply build on black magic.