34 lines
1.8 KiB
HTML
34 lines
1.8 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>AVR8js CircuitJS1 Demo</title><link href="//fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet"><link rel="stylesheet" href="src.avr8js.css"></head><body> <h2>AVR8js CircuitJS1 Demo</h2> <div style="width:50%;position:fixed;left:0;">
|
|
|
|
<iframe id="circuitFrame" width="95%" height="800" src="../circuitjs.html?startCircuit=avr8js-analog.txt&running=false"></iframe>
|
|
<p> <a href="index.html">LED strobe</a>, <a href="logic.html">Logic</a>, <a href="analog.html">Analog Read</a></p>
|
|
|
|
</div> <div style="width:50%;position:fixed;right:0;">
|
|
<p>Click Run below to start the simulation.</p>
|
|
<div class="toolbar"> <button id="run-button">Run</button> <button id="stop-button" disabled="">Stop</button> <button id="revert-button">Back to initial example</button> <div class="spacer"></div> <div id="status-label"></div> </div> <div class="code-editor"></div> <div class="compiler-output"> <pre id="compiler-output-text"></pre> <pre id="serial-output-text"></pre> </div> </div> <script src="//cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.21.2/min/vs/loader.js"></script> <script>
|
|
|
|
window.defaultCode=`
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
pinMode(8, OUTPUT);
|
|
pinMode(9, OUTPUT);
|
|
pinMode(10, OUTPUT);
|
|
pinMode(11, OUTPUT);
|
|
pinMode(12, OUTPUT);
|
|
}
|
|
|
|
void loop() {
|
|
// create labeled node with name A0 to access analog pin A0
|
|
int a = analogRead(0);
|
|
digitalWrite(8, (a & 512) != 0);
|
|
digitalWrite(9, (a & 256) != 0);
|
|
digitalWrite(10, (a & 128) != 0);
|
|
digitalWrite(11, (a & 64) != 0);
|
|
digitalWrite(12, (a & 32) != 0);
|
|
}
|
|
`;
|
|
|
|
</script> <script src="src.avr8js.js"></script> </body></html>
|
|
|