CÓDIGOS 

Comunicación arduino excel

float pinoPotenciometro = 0; // pin que define el potenciometro.

int ficha = 0; // variable que se refere las fichas

int LABEL = 2;

int valor = 0; // variable que guarda o valor leido del potenciometro

int potencia=0;

void setup()

 {

     Serial.begin(9600); // iniciamos la comunicacion serial

     Serial.println("CLEARDATA"); // Reset de comunicacion serial

    Serial.println("LABEL,Hora,valor,ficha,potencia"); // Nombre de las columnas

}

void loop(){

     valor = analogRead(pinoPotenciometro); // el valor del potenciometro guarda en valor.

   ficha++; // incrementa la ficha

   potencia++;

    Serial.print("DATA,TIME,"); //inicia la imprecion de datos

    Serial.print(valor);

    Serial.print(",");

   Serial.print(ficha);

  Serial.print(",");

   Serial.println (potencia);

  if (ficha > 100) //limitamos la cantidad de fichas

{

ficha = 0;

potencia = 0;

Serial.println("ROW,SET,3"); // iniciamos imprimiendo los datos en la pocicion 2,2

}

delay(1000); // tiempo de muestreo en milisegundos

}

CÓDIGO MEDIDOR DE CABLES

#include <LiquidCrystal.h> //librería para lcd       el sensor a usado es el opto interruptor esta en sección precios.

const int rs = 12, en = 11, d4 = 6, d5 = 5, d6 = 4, d7 = 3; //configuración de los pines para lcd

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

float medida=0; //variables

float fac=0.0869; //constante que multiplica cada vez que da un pulso el encoder

long lastReportedPos =0;  //valor anterior

enum PinAssignments {

encoderPinA = 2;

clearButton = 8;

};

volatile unsigned long encoderPos = 0;

boolean A_set = false;

void setup() {

lcd.begin(16, 2);

// Print a message to the LCD.

//lcd.print("proisev");

pinMode(encoderPinA, INPUT);

pinMode(clearButton, INPUT);

digitalWrite(encoderPinA, HIGH); // turn on pullup resistor

digitalWrite(clearButton, HIGH);

// encoder pin on interrupt 0 (pin 2)

attachInterrupt(0, doEncoderA, CHANGE);

Serial.begin(57600);

}

void loop(){

if (lastReportedPos != encoderPos) {

Serial.println(encoderPos);

medida=encoderPos*fac;

lcd.setCursor(0,1); // Seteamos la ubicacion texto 0 linea 1 que sera escrita sobre el LCD

lcd.print(medida);

lastReportedPos = encoderPos;

}

if (digitalRead(clearButton) == LOW) {

encoderPos = 0;

lcd.clear();

}

lcd.setCursor(4,0); // Seteamos la ubicacion texto 0 linea 1 que sera escrita sobre el LCD

lcd.print("proisev");

lcd.setCursor(7,1); // Seteamos la ubicacion texto 0 linea 1 que sera escrita sobre el LCD

lcd.print("metros");

}

// Interrupt on A changing state

void doEncoderA(){

// Test transition

A_set = digitalRead(encoderPinA) == HIGH;

// and adjust counter + if A leads B

if (A_set == 1) { encoderPos ++;}

}

Codigo seguidor de linea

int MdirectionA = 4, velocityA = 5, MdirectionB = 7, velocityB = 6; // VELOCIDAD Y DIRECCION DE LOS MOTORES A Y B

int pinR = 2, pinL = 3, followerR, followerL; // PINS DE LOS SENSORES SEGUIDORES DE LÍNEA

void setup() {

//CONFIGURACIÓN DE LOS PUERTOS 

pinMode ( MdirectionA, OUTPUT);

pinMode ( velocityA, OUTPUT);

pinMode ( MdirectionB, OUTPUT);

pinMode ( velocityB, OUTPUT);

pinMode (pinR, INPUT);

pinMode (pinL, INPUT);

}

void loop() {

// LECTURA DE LOS SENSORES SEGUIDORES DE LÍNEA

followerR = digitalRead (pinR);

followerL = digitalRead (pinL);

if ((followerR == 0)& (followerL == 0)) // AVANZAR HACIA DELANTE

{

//MOTOR B

analogWrite (velocityB, 110); // VELOCIDAD EL MOTOR-B, ES DE 0 (STOP) A 255 (MAXIMA VELOCIDAD)

digitalWrite ( MdirectionB,LOW); // SENTIDO DE GIRO MOTOR-B, LOW (DELANTE), HIGH (ATRÁS)

//MOTOR A

analogWrite (velocityA, 110); // VELOCIDAD EL MOTOR-A, ES DE 0 (STOP) A 255 (MAXIMA VELOCIDAD)

digitalWrite ( MdirectionA,LOW); // SENTIDO DE GIRO MOTOR-A, HIGH (DELANTE), LOW (ATRÁS)

}

if ((followerR == 0)& (followerL == 1)) //RIGHT - DERECHA

{

//MOTOR B

analogWrite (velocityB, 0); // VELOCIDAD EL MOTOR-B, ES DE 0 (STOP) A 255 (MÁXIMA VELOCIDAD)

digitalWrite ( MdirectionB,LOW); // SENTIDO DE GIRO MOTOR-B, LOW (DELANTE), HIGH (ATRÁS)

//MOTOR A

analogWrite (velocityA, 110); // VELOCIDAD EL MOTOR-A, ES DE 0 (STOP) A 255 (MÁXIMA VELOCIDAD)

digitalWrite ( MdirectionA,LOW); // SENTIDO DE GIRO MOTOR-A, HIGH (DELANTE), LOW (ATRÁS)

}

if ((followerR == 1)& (followerL == 0)) //LEFT - IZQUIERDA

{

//MOTOR B

analogWrite (velocityB, 110); // VELOCIDAD EL MOTOR-B, ES DE 0 (STOP) A 255 (MÁXIMA VELOCIDAD)

digitalWrite ( MdirectionB,LOW); // SENTIDO DE GIRO MOTOR-B, LOW (DELANTE), HIGH (ATRÁS)

//MOTOR A

analogWrite (velocityA, 0); // VELOCIDAD EL MOTOR-A, ES DE 0 (STOP) A 255 (MÁXIMA VELOCIDAD)

digitalWrite ( MdirectionA,LOW); // SENTIDO DE GIRO MOTOR-A, HIGH (DELANTE), LOW (ATRÁS)

}

if ((followerR == 1)& (followerL == 1)) //BACK - ATRÁS

{

//MOTOR B

analogWrite (velocityB, 110); // VELOCIDAD EL MOTOR-B, ES DE 0 (STOP) A 255 (MÁXIMA VELOCIDAD)

digitalWrite ( MdirectionB,LOW); // SENTIDO DE GIRO MOTOR-B, LOW (DELANTE), HIGH (ATRÁS)

//MOTOR A

analogWrite (velocityA, 110); // VELOCIDAD EL MOTOR-A, ES DE 0 (STOP) A 255 (MÁXIMA VELOCIDAD)

digitalWrite ( MdirectionA,LOW); // SENTIDO DE GIRO MOTOR-A, HIGH (DELANTE), LOW (ATRÁS)

}

}

envió excel arduino

/////desarollado por loxfile. desarollo y control de sistemas mecanicos

/////total auditoria

#include <SoftwareSerial.h>

int sp=0,pocicion=0;

byte slc=0;

char ingres[8];

const int ledPin = 5;

void setup() {

Serial.begin(9600);

pinMode(ledPin, OUTPUT);

}

void loop(){

// send data only when you receive data:

while (Serial.available() > 0) {

memset(ingres, 0,sizeof(ingres));

while (Serial.available() > 0) {

delay(5);

ingres[pocicion] = Serial.read();

pocicion++;

}

}

pocicion=0;

sp=atoi(ingres);

delay(100);

analogWrite(ledPin,sp );

}

webnode creada para desarrollo de proyectos
Creado con Webnode
CREADO CON WEBNODE ¿Estás pensando en vender online? Abre tu propia tienda online. ¿Quieres vender por Internet? Abre tu tienda. Elige una plantilla de tienda y empieza a vender hoy mismo.