Skip to content

Commit

Permalink
Merge pull request #126 from sol-oyarce/main
Browse files Browse the repository at this point in the history
agregar apuntes sol-oyarce
  • Loading branch information
montoyamoraga authored Sep 10, 2024
2 parents 6f92e25 + 92eaeaf commit f18f3d1
Showing 1 changed file with 85 additions and 88 deletions.
173 changes: 85 additions & 88 deletions 12-sol-oyarce/clase-05/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@ No nos funciono la biblioteca del sensor CapacitiveSensor.h
https://www.rinconingenieril.es/sensor-capacitivo/
codigo :

//Sensor Tactil capacitivo por Rincon Ingenieril
//Uso de la libreria CapacitiveSensor.h de Paul Stroffregen

#include <CapacitiveSensor.h>

CapacitiveSensor sensor = CapacitiveSensor(4,3);

void setup()
{
// put your setup code here, to run once:
pinMode(12,OUTPUT);
}

void loop()
{
// put your main code here, to run repeatedly:
long lectura = sensor.capacitiveSensor(30);

if(lectura>1)
digitalWrite(12,HIGH);
else
digitalWrite(12,LOW);

delay(10);
}
//Sensor Tactil capacitivo por Rincon Ingenieril
//Uso de la libreria CapacitiveSensor.h de Paul Stroffregen
#include <CapacitiveSensor.h>
CapacitiveSensor sensor = CapacitiveSensor(4,3);
void setup()
{
// put your setup code here, to run once:
pinMode(12,OUTPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
long lectura = sensor.capacitiveSensor(30);
if(lectura>1)
digitalWrite(12,HIGH);
else
digitalWrite(12,LOW);
delay(10);
}


CONEXION DEL ARDUINO
Expand All @@ -76,50 +76,50 @@ CONEXION DEL ARDUINO
codigo:


//Libraries
#include <CapacitiveSensor.h>//https://github.com/PaulStoffregen/CapacitiveSensor
//Parameters
bool autocal = 0;
const int numReadings = 10;
long readings [numReadings];
int readIndex = 0;
long total = 0;
const int sensitivity = 1000;
const int thresh = 200;
const int csStep = 10000;
CapacitiveSensor cs = CapacitiveSensor(2, 3);
void setup() {
//Init Serial USB
Serial.begin(9600);
Serial.println(F("Initialize System"));
//Init cs
if (autocal == 0) {
{
cs.set_CS_AutocaL_Millis(0xFFFFFFFF);
}
}
}
void loop() {
Serial.println(smooth());
}
long smooth() { /* function smooth */
////Perform average on sensor readings
long average;
// subtract the last reading:
total = total - readings[readIndex];
// read the sensor:
readings[readIndex] = cs.capacitiveSensor(sensitivity);
// add value to total:
total = total + readings[readIndex];
// handle index
readIndex = readIndex + 1;
if (readIndex >= numReadings) {
readIndex = 0;
}
// calculate the average:
average = total / numReadings;
return average;
}
//Libraries
#include <CapacitiveSensor.h>//https://github.com/PaulStoffregen/CapacitiveSensor
//Parameters
bool autocal = 0;
const int numReadings = 10;
long readings [numReadings];
int readIndex = 0;
long total = 0;
const int sensitivity = 1000;
const int thresh = 200;
const int csStep = 10000;
CapacitiveSensor cs = CapacitiveSensor(2, 3);
void setup() {
//Init Serial USB
Serial.begin(9600);
Serial.println(F("Initialize System"));
//Init cs
if (autocal == 0) {
{
cs.set_CS_AutocaL_Millis(0xFFFFFFFF);
}
}
}
void loop() {
Serial.println(smooth());
}
long smooth() { /* function smooth */
////Perform average on sensor readings
long average;
// subtract the last reading:
total = total - readings[readIndex];
// read the sensor:
readings[readIndex] = cs.capacitiveSensor(sensitivity);
// add value to total:
total = total + readings[readIndex];
// handle index
readIndex = readIndex + 1;
if (readIndex >= numReadings) {
readIndex = 0;
}
// calculate the average:
average = total / numReadings;
return average;
}

## CODIGO UTILIZADO

Expand All @@ -129,28 +129,25 @@ long smooth() { /* function smooth */

// Create an instance of the ArduinoLEDMatrix class
ArduinoLEDMatrix matrix;

void setup() {

pinMode(2, INPUT);
pinMode(3, OUTPUT);
matrix.loadSequence(animation);
matrix.begin();
matrix.play(true);
pinMode(2, INPUT);
pinMode(3, OUTPUT);
}

void loop() {
if (digitalRead(2) == HIGH) {
digitalWrite(3, HIGH);
matrix.loadSequence(animation);
matrix.play(true);
delay(10000);
}
else {
digitalWrite(3, LOW);
matrix.play(false);
delay(1000);
}
if (digitalRead(2) == HIGH) {
digitalWrite(3, HIGH);
matrix.loadSequence(animation);
matrix.begin();
matrix.play(true);
delay(10000);
}
else {
digitalWrite(3, LOW);
matrix.play(false);
delay(1000);
}
}


Expand Down

0 comments on commit f18f3d1

Please sign in to comment.