Tumgik
#analoginput
adafruit · 1 year
Text
Tumblr media
PCB of the day! Add oodles of analog inputs with an 8-channel ADC 🔌📊🔧
Many microcontrollers have ADCs these days for reading analog/resistive sensors like potentiometers, thermistors, LDR light sensors, etc., but sometimes you need MOAR! or maybe you're using a single board computer like a Raspberry Pi that has no ADCs at all…the ADS7830 is an affordable 8-channel ADC with I2C interface, so it's easy to include with any platform. There are 2 address pins, so you could have 4 x 8 = 32 total ADC channels with chain-able Stemma QT cables. You can get up to 70 Ksamples per second, but only 8-bits of resolution, so it's suitable for rough sensor measurements. This would be a great way to add a ton of potentiometers to a build, especially if it contained a Raspberry Pi, prototype coming soon!
https://www.digikey.com/short/5t1w37hb
16 notes · View notes
epicjust · 2 years
Text
Audiocapture timer
Tumblr media
Audiocapture timer install#
Audiocapture timer serial#
Audiocapture timer code#
Audiocapture timer Pc#
Run the workflow and change the Value property of the Boolean operator.Set the Pin property of the DigitalOutput operator to 13.Run the workflow and check the text file data.Configure the FileName property of the CsvWriter operator with a file name ending in.This operator records input data into a text file. Optional: Connect a sensor to the analog input pin, e.g.Run the workflow and visualize the output of the analog source.
Audiocapture timer serial#
Configure the PortName property to point to the correct serial port where the Arduino is connected.In a new Bonsai workflow, insert an AnalogInput source.
Audiocapture timer code#
The code can be found in File > Examples > Firmata.
Upload StandardFirmata to your Arduino.
Exercise 6: Configure Arduino for real-time communication Thankfully, Arduino already includes a standard implementation of a very efficient binary protocol called Firmata that can be used for serial communication with external applications. This can be a challenging task, as you will see later.
Audiocapture timer Pc#
In order to communicate and interact with an Arduino using Bonsai, you must setup a protocol for sending data to and from your host PC to the Arduino (via the USB cable).
Run the workflow and check that binary samples have been correctly recorded.
Connect the AmplifierData to the MatrixWriter operator.
Select the Rhd2000DataFrame > AmplifierData member from the context menu.
Right-click the Rhd2000EvalBoard operator.
Replace the AudioCapture source by an Rhd2000EvalBoard source.
Audiocapture timer install#
Install the Bonsai - Ephys Library from the package manager.
Open the resulting binary file in MATLAB/Python/R and check that binary samples have been correctly recorded.Įxercise 5 (Optional): Record raw data from an OpenEphys board.
Configure the Path property of the MatrixWriter operator with a file name ending in.
Replace the AudioWriter operator with a MatrixWriter sink.
Run the workflow for some seconds and check that it generates a valid audio file.Įxercise 4: Saving raw binary waveform data.
Make sure that the SamplingFrequency property of the AudioWriter matches the frequency of audio capture.
Configure the FileName property of the AudioWriter operator with a file name ending in.
For this reason, such multi-sample, multi-channel data is also typically represented as a 2D matrix of amplitude values, where rows represent channels, and columns represent time. Also, multiple audio channels can be acquired simultaneously in the case of a stereo microphone, or high-density ephys probes. However, the data is typically buffered into chunks of multiple samples before being sent to the computer.
Modify the workflow so that it records both a colour and a grayscale movie.Īudio data is captured at much higher temporal sampling frequencies than video.
The output should now be a grayscale movie.
Insert a Grayscale transform between CameraCapture and VideoWriter.
Run the workflow and check that it generates a valid video file.
Configure the FileName property of the VideoWriter operator with a file name ending in.
Each pixel represents either a brightness value in a grayscale image, or a BGR colour value in a colour image. The first data type we will discuss is an image, which is represented as a 2D matrix of pixels. The exercises below will make you comfortable with the most common Bonsai data types.
Read for an introduction to the user interface.īonsai can be used to acquire and record data from many different devices.
Click the Updates tab on the left side of the screen and install any available upgrades.
Install Bonsai - Starter Pack from the package manager.
Tumblr media
0 notes
taekyeom · 7 years
Video
instagram
Students work from my Interaction Design I. #processing #arduino #arduinouno #analoginput #digitalvisual #lightsensor #studentwork #interactiondesign (at Wey Hall)
1 note · View note
terakuhn · 4 years
Photo
Tumblr media
Image shows DebugAVR running the Arduino AnalogInput example program. The DebugAVR released today fixes issues with breakpoints and the simulation of the LDI instruction opcode. Find out more from the teraKUHN web site at http://terakuhn.weebly.com/debug_avr_app.html
1 note · View note
nans-gurvan · 4 years
Text
Séance 23 : 10/03/2021
Aujourd'hui nous avons réalisé une partie de la vidéo de présentation de notre projet, ce qui nous a prit une part importante de Norte séance. 
Néanmoins nous sommes parvenus à programmer un petit morceau de code permettant de lire une tension avec l’Arduino. le montage fonctionne avec une alimentation stabilisée, il faudra tester en condition réelles pour confirmer nos dires. 
int analogInput = 0; float vin = 0.0; float R1 = 10.55; // resistance of R1 (10M) float R2 = 2.69; // resistance of R2 (2,7M) int value = 0;
void setup(){   Serial.begin(9600);   pinMode(analogInput, INPUT); } void loop(){   // read the value at analog input   value = analogRead(analogInput);   vin = (value*5) / 1024.0; // see text   if (vin<0.09) {   vin=0.0;//statement to quash undesired reading ! }  Serial.println(value);  Serial.println(vin);  Serial.println("-----------");  delay(2000); }
0 notes
sergio-hernandez · 4 years
Text
Interruptor de presión DIY
El interruptor de presión DIY, es un dispositivo de entrada análogo bastante sencillo, basado en dos placas pequeñas de cartón, con superficies conductoras adheridas a ellas, y separadas por un elemento elástico como una esponja o un material similar, como se muestra en las fotografías:
Tumblr media Tumblr media
El interruptor de presión se utilizará con dos códigos de los que vienen como ejemplo en el programa de Arduino: AnalogInput y Smoothing
AnalogInput
El código AnalogInput, como ya lo habíamos visto en un post anterior, enciende y apaga un LED con diferente frecuencia, dependiendo de la lectura que hace Arduino desde un dispositivo análogo, como es el de la resistencia variable de un potenciómetro.
En este caso, esa misma lectura variable se realiza desde el interruptor de presión DIY, como se muestra en el video:
youtube
Smoothing
El código Smoothing, que también forma parte de los ejemplos del programa de Arduino, se diferencia del anterior porque no tiene una salida física, como una luz LED o un dispositivo de audio.
La salida del código es una salida digital, por medio de un display o ventana gráfica, que muestra los valores de interrupción de la conexión.
La entrada, en cambio, es análoga, al igual que en el caso anterior, de modo que la placa lee la resistencia del interruptor, y la muestra en valores numéricos en pantalla.
El código lo podemos ver a continuación, debidamente comentado, y como es habitual, con las secciones activas en negrita, y los comentarios en cursiva:
/*  Smoothing
 Reads repeatedly from an analog input, calculating a running average and  printing it to the computer. Keeps ten readings in an array and continually  averages them.
 The circuit:  - analog sensor (potentiometer will do) attached to analog input 0
 created 22 Apr 2007  by David A. Mellis  <[email protected]>  modified 9 Apr 2012  by Tom Igoe
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/Smoothing */
// Define the number of samples to keep track of. The higher the number, the // more the readings will be smoothed, but the slower the output will respond to // the input. Using a constant rather than a normal variable lets us use this // value to determine the size of the readings array. const int numReadings = 10;
int readings[numReadings];      // the readings from the analog input int readIndex = 0;              // the index of the current reading int total = 0;                  // the running total int average = 0;                // the average
int inputPin = A0;
void setup() {  // initialize serial communication with computer:  Serial.begin(9600);  // initialize all the readings to 0:  for (int thisReading = 0; thisReading < numReadings; thisReading++) {    readings[thisReading] = 0;  } }
void loop() {  // subtract the last reading:  total = total - readings[readIndex];  // read from the sensor:  readings[readIndex] = analogRead(inputPin);  // add the reading to the total:  total = total + readings[readIndex];  // advance to the next position in the array:  readIndex = readIndex + 1;
 // if we're at the end of the array...  if (readIndex >= numReadings) {    // ...wrap around to the beginning:    readIndex = 0;  }
 // calculate the average:  average = total / numReadings;  // send it to the computer as ASCII digits  Serial.println(average);  delay(1);        // delay in between reads for stability }
El resultado del uso de este código, con el mismo interruptor digital DIY, se puede ver en en siguiente video:
youtube
0 notes
Physical Computing, Week Two – Resistance is Futile
This week, we continued to develop our basic Arduino skills by taking a look at variable resistors, or more specifically the Light Dependant Resistor (LDR) and the potentiometer. Both of these resistors can change the level of current which they allow through, hence their name, and so can be used in a number of interesting ways. To experiment with these resistors, I created two circuits, one of which uses an LDR and one which use a potentiometer. In today’s update, I’ll be talking in more detail about these circuits and how they utilise variable resistors.
Tumblr media
The first circuit I made uses a Light Dependant Resistor to control the brightness of an LED. However, unlike in a conventional circuit, where the brightness of the LED would decrease as the resistance of the LDR increases, the Arduino allows us to script the circuit such that the LED actually gets brighter when there is more resistance. This allows us to create a system in which the LED lights up in the dark and turns itself off in the light. Shown below is the script which makes this behaviour possible:
int sensorPin = A0;   // select the input pin for the potentiometer int ledPin = 13;      // select the pin for the LED int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {
 // declare the ledPin as an OUTPUT:
 pinMode(ledPin, OUTPUT);
}
void loop() {
// read the value from the sensor: sensorValue = analogRead(sensorPin); // turn the ledPin on if(sensorValue < 256){
analogWrite(ledPin, 256  - (sensorValue));
}
// stop the program for 250 milliseconds: delay(250); // turn the ledPin off: analogWrite(ledPin, LOW); // stop the program for for 250 milliseconds: delay(250);
}
As the script shows, the Arduino first reads the value of the LDR (the resistance), then sets the brightness of the LED to 256 minus this value. The result is that as resistance approaches 0Ω, the value subtracted from 256 becomes smaller, and thus the overall brightness becomes greater. Footage of this behaviour can be found here in a simple on/off format, though changing the light level gradually will also result in a more incremental change to the brightness of the LED.
The second circuit I constructed makes use of a potentiometer, a three-pin potential divider which acts as a variable resistor when just two pins are connected to the circuit. This particular circuit is controlled by the example script AnalogInput, which can be found in the Arduino IDE. The script sets the LED flashing continually, but allows the interval between flashes to be changed depending on the resistance of the potentiometer. The circuit itself is very similar to the first, though the LDR has of course been substituted for a potentiometer. The diagram for this circuit is shown below, and footage of the circuit in action can be found here.
Tumblr media
While these circuits are slightly more complex than those constructed last week, they are still limited in their scope at this time, with both serving only to control the brightness and interval of a flashing LED. Nevertheless, the potential for ‘analogue’ circuits, which can control the flow of electricity through variable resistors such as the LDR and potentiometer, is quite promising, and I look forward to being able to use such components in more complex systems. Indeed, they may prove useful in creating my final experiment for this module.
0 notes
Text
ARDUINO
Ejemplo 3: “AnalogInPut”
0 notes
Text
Tarea > Ejemplos > 03 Analog > AnalogInput B
En este ejercicio utilizamos el arduino y el código, para usar una salida análoga y conectarlo a un sensor de luz que ir variando la velocidad con la que parpadea la luz led.
0 notes
cdavalo1-blog · 10 years
Video
undefined
tumblr
ASSIGNMENT#4
  const int analogInPin = A1;
const int analogOutPin0 = 3;
const int analogOutPin1 = 5;
const int analogOutPin2 = 6;
const int analogOutPin3 = 9;
const int analogOutPin4 = 10;
const int analogOutPin5 = 11;
  int sensorValue = 0;
int lightValue = 0;
  void setup()
{
  Serial.begin(9600);
}
  void loop()
{
  sensorValue = analogRead(analogInPin);           
  lightValue=map(sensorValue,0,1023,0,600);
  while(lightValue>0)
  {
      analogWrite(analogOutPin0,3);
      lightValue=map(sensorValue,0,1023,0,600);
        while(lightValue>100)
    {
      analogWrite(analogOutPin1,3);
      lightValue=map(sensorValue,0,1023,0,600);
            while(lightValue>200)
      {
        analogWrite(analogOutPin2,3);
        lightValue=map(sensorValue,0,1023,0,600);
               while(lightValue>300)
        {
          analogWrite(analogOutPin3,3);
          lightValue=map(sensorValue,0,1023,0,600);
                    while(lightValue>400)
          {
            analogWrite(analogOutPin4,3);
            lightValue=map(sensorValue,0,1023,0,600);
                        while(lightValue>500)
            {
              analogWrite(analogOutPin5,3);
              lightValue=map(sensorValue,0,1023,0,600);
              break;
            }
            break;
          }
          break;
        }
        break;
      }
      break;
    }
    break;
  }
      lightValue=map(sensorValue,0,1023,0,600);
  while(lightValue==0)
  {
  analogWrite(analogOutPin5,LOW);
  delay(50);
  analogWrite(analogOutPin4,LOW);
  delay(50);
  analogWrite(analogOutPin3,LOW);
  delay(50);
  analogWrite(analogOutPin2,LOW);
  delay(50);
  analogWrite(analogOutPin1,LOW);
  delay(50);
  analogWrite(analogOutPin0,LOW);
  delay(50);
  break;
  }
  Serial.print("sensor = " );                      
  Serial.print(sensorValue);     
  Serial.print("\t output = ");     
  Serial.println(lightValue);  
    delay(2);                    
}
0 notes
taekyeom · 7 years
Video
instagram
Arduino + Processing. It's a project for my interaction design I class and fun! My processing sketch receives the analog input from a light sensor and visualize the data. #processing #arduino #arduinouno #analog #analoginput #digitalvisual #lightsensor (at Wey Hall)
1 note · View note
Text
Can't Beat Without You - a Combo Lock Object
Assignment Requirement
Adapt past homework or make a creature whose body can effect another part of its body, or its environment. Simple example - a flex sensor in its arm, when you bend the arm its eye fade in and out. Another example - two small creatures when they hug each other in the right combination, their house lights up. Try to use lots of LEDs, not just one. Try to use a variable resistor, not just switches. Bonus for output that is something besides LEDs.
Brief Intro to Can't Beat Without You
Tumblr media
Can't Beat Without You is a simple interactive toy with two cardboard box characters, a "girl" and a "boy". A sensor is put into the "girl" sensing the distance between she and the "boy". When the "boy" get closer to her within a certain sensible distance, the LED heart of the "girl" start beating and you can hear the heartbeat sound from a little speaker. If the "boy" move away from the sensible range, the "heartbeat" stop.
Materials
External: 2 snack cardboard boxes
Internal: Sharp IR sensor GP2Y0A21YK, 8 ohm loudspeaker, Red LED, 1 330v resistor, Arduino Leonado board, 9v battery
Cricuit
Tumblr media
Process
Tumblr media
Played with the speaker
Tumblr media
Got the project idea
Tumblr media
Spent lots of time (again) figuring out the circuit
Tumblr media
Making the external look with snack box
Tumblr media Tumblr media
Put the circuit into the "girl"
Arduino Code
int sensorpin = A0; // analog pin used to connect the sharp sensor //add an led on 8 const int ledPin = 8; const int speakerPin = 9; int val = 0; // variable to store the values from sensor(initially zero)
void setup() { Serial.begin(9600); // starts the serial monitor //set the LED as output pinMode(ledPin, OUTPUT); pinMode(speakerPin, OUTPUT); } void loop() { val = analogRead(sensorpin); // reads the value of the sharp sensor Serial.println(val); // prints the value of the sensor to the serial monitor if (val>400) { //turn the LED on digitalWrite(ledPin, HIGH); tone(9,250,10); delay(300); digitalWrite(ledPin,LOW); delay(100); digitalWrite(ledPin, HIGH); tone(9,250,10); delay(300); digitalWrite(ledPin,LOW); delay(1000);
}else { digitalWrite(ledPin, LOW); noTone(9); delay(100); } // wait for this much time before printing next value }
  Difficulties
-Transform the voltage into sensing distance, get stuck in the codes.
-Can't figure out how to use the map() and constrain() function in this case.
  Experience
-If you get stuck, just restart from the very beginning of the circuit. In this project case, for a long time that I couldn't get the sensor working. Something wrong with the code that  the sensor fail to control the heartbeat within a certain distance. Then I took the suggestion to restart the whole thing from getting SerialPrintln() numbers of the IR sensor. After that, I link the IR sensor with the LED and modify the code, utilizing the range number of the IR sensor directly to set the sensing distance. 
-SerialPrintln() is helpful for checking state and debugging
-Pseudocode is helpful to clear your mind before writing the real code.
Video
http://youtu.be/zjJ8ol8j0sM
Reference Materials
IR sensor : http://communityofrobots.com/tutorial/kawal/how-use-sharp-ir-sensor-arduino
Calibration - define the minimum and maximum of expected values for the readings taken during the loop http://arduino.cc/en/Tutorial/Calibration
0 notes
taekyeom · 7 years
Video
instagram
Student work! Arduino + Processing project from my interactive design I. The Processing sketch takes the analog input from the arduino board to generate those shapes and/or colors. #arduino #analoginput #processing #studentwork #generativedesign #lightsensor #photocell #interactivedesign #physicalcomputing #finals
0 notes
sergio-hernandez · 4 years
Text
Ejercicios con Arduino: ANALOG INPUT
El código ANALOG INPUT es uno de los ejemplos que vienen incluidos en el programa de Arduino, en el apartado “Analog”, pues define un input análogo, o de operación manual, para el accionamiento del LED incorporado en la placa, y que se puede conducir a lun LED externo.
ANALOG INPUT hace que un diodo o luz led se encienda y apague gradualmente, accionando un potenciómetro conectado a los pines de entrada o input análogos de la placa.
Copio el código a continuación:
/*  Analog Input
 Demonstrates analog input by reading an analog sensor on analog pin 0 and  turning on and off a light emitting diode(LED) connected to digital pin 13.  The amount of time the LED will be on and off depends on the value obtained  by analogRead().
 The circuit:  - potentiometer    center pin of the potentiometer to the analog input 0    one side pin (either one) to ground    the other side pin to +5V  - LED    anode (long leg) attached to digital output 13    cathode (short leg) attached to ground
 - Note: because most Arduinos have a built-in LED attached to pin 13 on the    board, the LED is optional.
 created by David Cuartielles  modified 30 Aug 2011  By Tom Igoe
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/AnalogInput */
int sensorPin = A0;    // select the input pin for the potentiometer int ledPin = 13;      // select the pin for the LED int sensorValue = 0;  // variable to store the value coming from the sensor
void setup() {  // declare the ledPin as an OUTPUT:  pinMode(ledPin, OUTPUT); }
void loop() {  // read the value from the sensor:  sensorValue = analogRead(sensorPin);  // turn the ledPin on  digitalWrite(ledPin, HIGH);  // stop the program for <sensorValue> milliseconds:  delay(sensorValue);  // turn the ledPin off:  digitalWrite(ledPin, LOW);  // stop the program for for <sensorValue> milliseconds:  delay(sensorValue); }
El código propiamente tal está en negrita, y los comentarios explicativos en cursiva.
En el video se explica en detalle el código, y se muestra su funcionamiento una vez cargado en la placa Arduino UNO, y conectado a la protoboard.
youtube
VARIANTE DEL OUTPUT
Adicionalmente se realizó una variante del OUTPUT o salida, conectándolo  un dispositivo de audio (parlante), como se muestra en el video:
youtube
0 notes
Text
ARDUINO
Ejemplo 3: “AnalogInPut”
Tumblr media Tumblr media
0 notes
Text
Tarea > Ejemplos > 03 Analog > AnalogInput A
En este ejercicio utilizamos el arduino y el código, para usar una salida análoga he ir variando la velocidad con la que parpadea la luz led.
0 notes