emg

Oficina Corpo Máquina: Arduino +Biofeedback

http://www.sescsp.org.br/sesc/programa_new/mostra_detalhe.cfm?programacao_id=238890

“Utilizando placas de prototipagem eletrônica de hardware livre, esta atividade tem como objetivo desenvolver uma interface de computação física para sensoriamento de estímulos elétricos produzidos por músculos do corpo humano, a fim de operar dispositivos eletrônicos analógicos e digitais em conjunto com visualizações de dados para biofeedback. [Biofeedback é uma das áreas de maior desenvolvimento no campo da medicina de comportamento nos Estados Unidos, que permite à pessoa voluntariamente regular suas reações fisiológicas e emocionais através de aparelhos sensórios eletrônicos]. Orientação: Guima San. Duração 15 encontros. A partir de 16 anos. 20 vagas. 1º Pavimento. Inscrições pessoalmente a partir do dia 05/02 às 14h, no estacionamento da unidade.”

 

 


 

servobluetooth_bb

Arduino + Bluetooth – Servo Motor

servobluetooth_schem

#include <Servo.h>

long val;

Servo servoDireita, servoEsquerda;
int posicao_inicial_servo = 0;

int led0 = 13;
int led1 = 12;
int go = 50;
int bk = 56;
int lf = 52;
int rg = 54;
int led = 67;

void setup() {
//Inicia a comunicaço serial(USB ou Bluetooth)
Serial.begin(9600);
//Modo de operaçao dos pinos = Saida
pinMode(led0, OUTPUT);
pinMode(led1, OUTPUT);
//Escrita digital nos LEDs = Apagados
digitalWrite(led0, LOW);
digitalWrite(led1, LOW);
servoDireita.attach(5);
servoEsquerda.attach(6);
servoDireita.writeMicroseconds(1400);
servoEsquerda.writeMicroseconds(1400);
}
void loop() {
if( Serial.available() )
{
val = Serial.read();
}
if( val == go )//para frente
{
movimetacao_Frente();
}
else if( val == bk )
{
movimentacao_Re();
}
else if( val == lf )
{
movimentacao_Esquerda();
}
else if( val == rg )
{
movimentacao_Direita();
}
else if(val == 48 )
{
movimentacao_Parado();
}
else if (val == led)
{
digitalWrite(led0, HIGH);
digitalWrite(led1, HIGH);
delay(10);
}
else {
digitalWrite(led0, LOW);
digitalWrite(led1, LOW);
}
delay(100);
//Serial.println(val);
}

/*======== Movimentacao dos Servos ================*/

int movimetacao_Frente()
{
servoDireita.write(180);
servoEsquerda.write(0);
}
int movimentacao_Re()
{
servoDireita.write(0);
servoEsquerda.write(180);
}
int movimentacao_Direita()
{
servoDireita.write(75);
servoEsquerda.write(75);
}
int movimentacao_Esquerda()
{
servoDireita.write(105);
servoEsquerda.write(105);
}
int movimentacao_Parado()
{
servoDireita.writeMicroseconds(1400);
servoEsquerda.writeMicroseconds(1400);
}

 

SAMSUNG

pHmetro Atlas Scientific + Arduino Mega

Começando com a documentação do pHmetro >> http://atlas-scientific.com/product_pages/embedded/ph.html

Datasheet: http://atlas-scientific.com/_files/pH_Stamp_4.0.pdf

Características:

  • Faixa de leitura: .01 a 14.00;
  • Precisão dentro de 2 algorismos significativos (XX:XX);
  • Leituras simples ou contínuas;
  • Leituras dependentes ou independentes de temperatura; (isso é muito bom!!)
  • Protocola de calibração simples;
  • Conectividade RS-232 simples (balanço de voltagem 0-VCC);
  • Circuito micro impresso;
  • Debugging por LED’s;
  • Voltagem operacional entre 2.5V e 5.5V;
  • Baixo consumo de energia
    2mA em 3.3V no modo ativo*
    1.89mA em 3.3 no modo de espera*
    *com os LED’s apagados.

É importante ter em mente que somente utilizando as leituras de pH dependentes da temperatura, é que podemos considerá-las de nível científico.

Dica: O comprimento do fio que vai do sensor de pH para o circuito deve ser o mais curto possível para reduzir o ruído.

Diagrama esquemático: http://atlas-scientific.com/_files/instructions/Wiringdiagram.pdf

Exemplo de código e comunicação com arduino: http://atlas-scientific.com/_files/code/Arduino-sample-code-EZ-COM-MEGA.pdf


/*
This software was made to demonstrate how to quickly get your Atlas Scientific product running on the Arduino platform.
An Arduino MEGA 2560 board was used to test this code.
This code was written in the Arudino 1.0 IDE
Modify the code to fit your system.
**Type in a command in the serial monitor and the Atlas Scientific product will respond.**
**The data from the Atlas Scientific product will come out on the serial monitor.**
Code efficacy was NOT considered, this is a demo only.
The TX3 line goes to the RX pin of your product.
The RX3 line goes to the TX pin of your product.
Make sure you also connect to power and GND pins to power and a common ground.
Open TOOLS > serial monitor, set the serial monitor to the correct serial port and set the baud rate to 38400.
Remember, select carriage return from the drop down menu next to the baud rate selection; not "both NL & CR".
*/

String inputstring = ""; //a string to hold incoming data from the PC
String sensorstring = ""; //a string to hold the data from the Atlas Scientific product
boolean input_stringcomplete = false; //have we received all the data from the PC
boolean sensor_stringcomplete = false; //have we received all the data from the Atlas Scientific product

void setup(){ //set up the hardware
Serial.begin(38400); //set baud rate for the hardware serial port_0 to 38400
Serial3.begin(38400); //set baud rate for software serial port_3 to 38400
inputstring.reserve(5); //set aside some bytes for receiving data from the PC
sensorstring.reserve(30); //set aside some bytes for receiving data from Atlas Scientific product
}

void serialEvent() { //if the hardware serial port_0 receives a char
char inchar = (char)Serial.read(); //get the char we just received
inputstring += inchar; //add it to the inputString
if(inchar == '\r') {input_stringcomplete = true;} //if the incoming character is a , set the flag
}

void serialEvent3(){ //if the hardware serial port_3 receives a char
char inchar = (char)Serial3.read(); //get the char we just received
sensorstring += inchar; //add it to the inputString
if(inchar == '\r') {sensor_stringcomplete = true;} //if the incoming character is a , set the flag
}

void loop(){ //here we go....

if (input_stringcomplete){ //if a string from the PC has been recived in its entierty
Serial3.print(inputstring); //send that string to the Atlas Scientific product
inputstring = ""; //clear the string:
input_stringcomplete = false; //reset the flage used to tell if we have recived a completed string from the PC
}

if (sensor_stringcomplete){ //if a string from the Atlas Scientific product has been recived in its entierty
Serial.println(sensorstring); //send that string to to the PC's serial monitor
sensorstring = ""; //clear the string:
sensor_stringcomplete = false; //reset the flage used to tell if we have recived a completed string from the Atlas Scientific product
}
}

Vídeo sobre como conectar o circuito em uma placa serial RX-TX, pode-se usar a mesma lógico pra arduino:
watch?v=UIk6CAINpwo

Operações do dispositivo

Quando o circuito do pHmetro é conectado a uma fonte de energia (2.5V a 5.5V), um LED verde indica que a placa está ligada.

O cricuito entrará automaticamente no modo continuo e iniciará a comunicação serial, transmitindo as informações de leitura do pH.

Existem no total 11 diferentes comandos para operar o pHmetro que podem ser encontrados no datasheet já mencionado.

 

 

Computação física com Arduino

Computação física – SESC Sorocaba

1ª Oficina de Arduino no Sesc Sorocaba

Primeiro dia de oficina de Computação física com arduino, a galera montou um circuito simples para acionar um Led quando a intensidade de luz no ambiente diminuía.

Circuito:


Código:

// codigo ldr + led
int led = 13;
int sensor = A2;

void setup() {
pinMode(led, OUTPUT);
pinMode(sensor, INPUT);
Serial.begin(9600);
}

void loop() {
int val = analogRead(sensor);
Serial.println(val);

if (val < 300) {
digitalWrite(led, HIGH);
} else {
digitalWrite(led, LOW);
}
delay(200);
}

Controle de intensidade luminosa com o led no pino 11:

int led = 11;
int ldr = A2;
int calibri = 0;

void setup() {

Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(ldr, INPUT);
// calibra sensor aberto
digitalWrite(led, HIGH);
for (int i = 0; i<20000; i++) {
calibri = analogRead(A0);
}
digitalWrite(led, LOW);
delay (1000);
}

void loop () {
int sensor = analogRead(ldr);
Serial.println(sensor);
int brilho = map(sensor, 100, calibri, 0, 255);
analogWrite(led, brilho);
if (brilho < 1) {
digitalWrite(led, LOW);
}
delay(10);
}

eletrorganicas+processing

Eletrôrganicos + Processing

 

Usando este circuito http://gypsyware.org/experimentos-2/eletrorganicos/capsense_toque-nas-plantas/
e o código para o processing:

// Graphing sketch

// This program takes ASCII-encoded strings
// from the serial port at 9600 baud and graphs them. It expects values in the
// range 0 to 1023, followed by a newline, or newline and carriage return

// Created 20 Apr 2005
// Updated 18 Jan 2008
// by Tom Igoe
// This example code is in the public domain.

import processing.serial.*;

Serial myPort; // The serial port
int xPos = 1; // horizontal position of the graph

void setup () {
// set the window size:
size(800, 600);

// List all the available serial ports
println(Serial.list());
// I know that the first port in the serial list on my mac
// is always my Arduino, so I open Serial.list()[0].
// Open whatever port is the one you're using.
myPort = new Serial(this, Serial.list()[0], 9600);
// don't generate a serialEvent() unless you get a newline character:
myPort.bufferUntil('\n');
// set inital background:
background(0);
}
void draw () {
// everything happens in the serialEvent()
}

void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');

if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);

// draw the line:
stroke(127,34,255);
line(xPos, height, xPos, height - inByte);

// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
}
else {
// increment the horizontal position:
xPos++;
}
}
}