Skip to content

Update recorcholis.cpp#1

Open
PedroHachaM wants to merge 1 commit intogleono:masterfrom
PedroHachaM:master
Open

Update recorcholis.cpp#1
PedroHachaM wants to merge 1 commit intogleono:masterfrom
PedroHachaM:master

Conversation

@PedroHachaM
Copy link

Primer implementación en IDE de arduino

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Seteamos la direccion I2C
// define los pines y variables usados, el pin 8 y 9 van conectados al driver DRV8825 que controla el motor a pasos

int sencillo = 2; //pin 2 conección del boton modo 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normalmente cuando son constantes como estas se escriben en mayúsculas y con el prefijo const.

Entonces se vería:

const int SENCILLO = 2;

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inclusive sería mas útil que fuera BTN_SENCILLO = 2, para saber inmediatamente que es el botón. Lo mismo para todas las demás constantes.

}
void loop() {

valorinicio = digitalRead (5); // Lee el boton inicio (botón verde) y asigna el estado a valorinicio
Copy link
Owner

@gleono gleono Jun 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si seguimos con el comentario de arriba, aquí en lugar del 5 sería

valorinicio = digitalRead(BTN_INICIO);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se entiende mejor de donde está leyendo y hace el comentario irrelevante.

int valorparo; //variable para guardar el estado (High - low) del boton paro
int reset = 7; //pin 7 conección del botón "reset"
int valorreset; //variable para guardar el estado (High - low) del boton reset
int sensor1 = 8; //pin 8 conexión del sensor1 "bajo las válvulas"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo lo llamaria:

const int SENSOR_VAL = 8;


// ---------------------------llenado del primer bolis----------------------------------

while (valsensor1 == LOW){ // mientras el sensor1 no detecte nada, el motor sigue girando, de lo contrario para
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cómo se actualiza el valor de valsensor1? En la línea 81? Hasta que se da toda la vuelta en el ciclo?

// -----------------------sellado y cortado del 1° y 2° bolis----------------------------------------

valsensor2 = digitalRead (9); // Lee el sensor1 y asigna el estado a valsensor1
while (valsensor2 == LOW ){ // mientras el sensor 2 no detecte nada...
Copy link
Owner

@gleono gleono Jun 1, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

creo que realmente lo que quieres hacer es:

while ((valsensor2 = digitalRead(SENSOR_SELL)) == LOW) { ... }

//-------------------------sellado y cortado del bolis 3-4, 5 y6. repito codigo?--------------------------------

//-------------------------contador de bolis-----------------------------
if (digitalRead(10) == HIGH){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cómo funciona esta doble lectura casi instantanea?

servo1.write (0); // regresa el servomotor a 0°
delay(500); // espera medio segundo
}
//-------------------------sellado y cortado del bolis 3-4, 5 y6. repito codigo?--------------------------------
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aun tengo que entender con este código, el usuario tendría que presionar el boton verde de inicio para hacer el llenado y sellado de cada bolis?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Si duplicaras el código otras 5 veces como le harías para contar los bolis? Osea las lineas siguientes este comentario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments