![]() To make this sketch work, your board must be connected to your computer. The code will be similar to your original code, but separate out the 'reading from the serial port' from 'deciding which function to call'. 5 LEDs 5 220 ohm resistors hook-up wires breadboard Circuit Five LEDs are attached to digital pins 2, 3, 4, 5, and 6 in series through 220 ohm resistors. Also in loop(), test the value of those variables to decide which function(s) need to be called, and then call them. In loop(), put your code to read the input commands and update the variables to show which functions are supposed to be being called. I use Arduini IDE 1.8.10 with VisualStudio and vMicro Plugin. Have some global variables which tell you which function(s) you should be calling. Rather than trying to code your functions so they run 'continuously', design them so that they are called repeatedly. do measurementS and RETURN DATA AS LONG AS USER PRESS ONE KEY TO STOP MEASUREMENT Some setup & variables/constants declaration & other stuff Core components: Arduino Uno, additional Arduino board (any), 3D printer filament. ![]() Here is my code //includes necessary libraries Arduino remote control light switch (Source: alanmerritt via Instructables). You should Consider that I'm absolutely not an expert programmer. Maybe I would like to obtain something that is conceptually wrong. I've search some help for a long time (almost all use the " millis()" function,or the " time.h" and " TimeAlarm.h" library, etc.) but after some attempts I can't obtain the result I need. This sketch will be used with an interface, built in Processing, that will ask Arduino to get the measurements: each value from "single measurement" (obtained from all the functions except those named " Pres()")will be represented in a "text box", whereas those from the "continuous measurements" (obtained from the " Pres()" function) will be plotted in a continuous graph (for example a graph similar to ). My own huge problems start when I need to create a measurement function (in this specific case a pressure measurement, but this doesn't really matter) that when it is called it runs forever its measurement routine, until User press the key to stop it. As It's wrote below, the sketch is working perfectly, especially if considering the situation in which every function returns one single value. In particular I've Imagined a sketch with a "switch case loop" for the function selection. I would like to create a sketch that execute some different function (sensor measurements) depending on which key is pressed by user.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |