Skip to content

Instantly share code, notes, and snippets.

@maxippacheco
Last active September 28, 2023 00:54
Show Gist options
  • Save maxippacheco/2c0f00ab148f2e221bee7310ae8fdfbc to your computer and use it in GitHub Desktop.
Save maxippacheco/2c0f00ab148f2e221bee7310ae8fdfbc to your computer and use it in GitHub Desktop.
This repository belongs to a practical word in the subject "Introduction to cyberphysicist systems"
<circuit version="1.0.0-SR1" rev="1402" stepSize="1000000" stepsPS="1000000" NLsteps="100000" reaStep="1000000" animate="0" >
<item itemtype="Subcircuit" CircId="Uno-2" mainComp="false" Show_id="true" Show_Val="false" Pos="772,528" rotation="0" hflip="1" vflip="1" idLabPos="0,-20" labelrot="0" valLabPos="-16,20" valLabRot="0" Logic_Symbol="false">
<mainCompProps itemtype="MCU" CircId="2_mega328-109" mainComp="true" Show_id="false" Show_Val="false" Pos="20,20" rotation="0" hflip="1" vflip="1" label="2_mega328-109" idLabPos="0,-20" labelrot="0" valLabPos="-16,20" valLabRot="0" Frequency="16 MHz" Program="../../sketch_sep27a/sketch_sep27a.ino.hex" Auto_Load="false" Rst_enabled="true" Ext_Osc="true" Wdt_enabled="false" />
</item>
<item itemtype="Voltimeter" CircId="Voltimeter-4" mainComp="false" Show_id="false" Show_Val="false" Pos="680,572" rotation="0" hflip="1" vflip="1" label="Voltimeter-4" idLabPos="-24,-40" labelrot="0" valLabPos="-16,20" valLabRot="0" />
<item itemtype="Battery" CircId="Battery-11" mainComp="false" Show_id="false" Show_Val="false" Pos="596,632" rotation="0" hflip="1" vflip="1" label="Battery-11" idLabPos="-18,-22" labelrot="0" valLabPos="-10,10" valLabRot="0" Voltage="5 V" Resistance="1e-14 Ω" />
<item itemtype="Push" CircId="Push-14" mainComp="false" Show_id="false" Show_Val="false" Pos="624,680" rotation="0" hflip="1" vflip="1" label="Push-14" idLabPos="-12,-24" labelrot="0" valLabPos="-16,20" valLabRot="0" Norm_Close="false" Poles="1 _Poles" />
<item itemtype="Connector" uid="connector-12" startpinid="Voltimeter-4-lPin" endpinid="Uno-2-13" pointList="672,588,672,680,752,680,752,656,780,656" />
<item itemtype="Connector" uid="connector-13" startpinid="Voltimeter-4-rPin" endpinid="Uno-2-GND2" pointList="688,588,688,664,780,664" />
<item itemtype="Connector" uid="Connector-16" startpinid="Push-14-switch0pinN" endpinid="Uno-2-4" pointList="640,680,640,708,728,708,728,576,780,576" />
<item itemtype="Connector" uid="Connector-17" startpinid="Push-14-pinP0" endpinid="Battery-11-lPin" pointList="608,680,608,664,572,664,572,632,580,632" />
</circuit>
int luz_del_led = 13;
int estado_del_led;
int barrera = 4;
int estado_barrera;
int tiempo = 1600000;
void setup() {
pinMode(luz_del_led, OUTPUT);
pinMode(barrera, INPUT);
}
void loop() {
estado_barrera = digitalRead(barrera);
if (estado_barrera == HIGH) {
digitalWrite(luz_del_led, HIGH);
} else {
for (volatile int i = 0; i < tiempo; i++) {
estado_del_led = digitalRead(luz_del_led);
if (estado_del_led == LOW) {
digitalWrite(luz_del_led, HIGH);
}
}
for (volatile int i = 0; i < tiempo; i++) {
estado_del_led = digitalRead(luz_del_led);
if (estado_del_led == HIGH) {
digitalWrite(luz_del_led, LOW);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment