print number

This commit is contained in:
KP9lKk 2025-03-28 13:20:44 +03:00
parent 9da3acb74f
commit 1315fc990e
2 changed files with 75 additions and 6 deletions

View File

@ -13,7 +13,34 @@
"left": 258.65,
"rotate": 90,
"attrs": { "value": "250" }
}
},
{
"type": "wokwi-resistor",
"id": "r2",
"top": 72,
"left": 287.45,
"rotate": 90,
"attrs": { "value": "250" }
},
{
"type": "wokwi-resistor",
"id": "r3",
"top": 72,
"left": 316.25,
"rotate": 90,
"attrs": { "value": "250" }
},
{
"type": "wokwi-resistor",
"id": "r4",
"top": 72,
"left": 345.05,
"rotate": 90,
"attrs": { "value": "250" }
},
{ "type": "wokwi-led", "id": "led2", "top": 102, "left": 291.8, "attrs": { "color": "red" } },
{ "type": "wokwi-led", "id": "led3", "top": 102, "left": 320.6, "attrs": { "color": "red" } },
{ "type": "wokwi-led", "id": "led4", "top": 102, "left": 349.4, "attrs": { "color": "red" } }
],
"connections": [
[ "uno:GND.1", "bb1:tn.1", "black", [ "v0" ] ],
@ -22,8 +49,29 @@
[ "uno:13", "bb1:6t.a", "green", [ "v0" ] ],
[ "r1:1", "bb1:6t.b", "", [ "$bb" ] ],
[ "r1:2", "bb1:6b.f", "", [ "$bb" ] ],
[ "r2:1", "bb1:9t.b", "", [ "$bb" ] ],
[ "r2:2", "bb1:9b.f", "", [ "$bb" ] ],
[ "r3:1", "bb1:12t.b", "", [ "$bb" ] ],
[ "r3:2", "bb1:12b.f", "", [ "$bb" ] ],
[ "r4:1", "bb1:15t.b", "", [ "$bb" ] ],
[ "r4:2", "bb1:15b.f", "", [ "$bb" ] ],
[ "bb1:tn.5", "bb1:8t.a", "green", [ "v0" ] ],
[ "bb1:tn.8", "bb1:11t.a", "green", [ "v0" ] ],
[ "bb1:tn.10", "bb1:14t.a", "green", [ "v0" ] ],
[ "led1:A", "bb1:6b.j", "", [ "$bb" ] ],
[ "led1:C", "bb1:5b.j", "", [ "$bb" ] ]
[ "led1:C", "bb1:5b.j", "", [ "$bb" ] ],
[ "led2:A", "bb1:9b.j", "", [ "$bb" ] ],
[ "led2:C", "bb1:8b.j", "", [ "$bb" ] ],
[ "led3:A", "bb1:12b.j", "", [ "$bb" ] ],
[ "led3:C", "bb1:11b.j", "", [ "$bb" ] ],
[ "led4:A", "bb1:15b.j", "", [ "$bb" ] ],
[ "led4:C", "bb1:14b.j", "", [ "$bb" ] ],
[ "uno:12", "bb1:9t.a", "green", [ "v0" ] ],
[ "uno:11", "bb1:12t.a", "green", [ "v0" ] ],
[ "uno:10", "bb1:15t.a", "green", [ "v0" ] ],
[ "bb1:8t.e", "bb1:8b.f", "green", [ "v0" ] ],
[ "bb1:11t.e", "bb1:11b.f", "green", [ "v0" ] ],
[ "bb1:14t.e", "bb1:14b.f", "green", [ "v0" ] ]
],
"dependencies": {}
}

View File

@ -1,13 +1,34 @@
#include <Arduino.h>
int pin13 = 13;
constexpr int size = 4;
int pins[size] = {13, 12, 11, 10};
int digits[size] = {0, 0, 0, 0};
void toBinary(int number){
for(size_t i = (size - 1); i != size_t(-1); i--){
digits[i] = number % 2;
Serial.println(number % 2);
number /= 2;
}
}
void setup() {
pinMode(pin13, OUTPUT);
for(const int& pin : pins){
pinMode(pin, OUTPUT);
}
}
void loop() {
delay(3000);
digitalWrite(pin13, HIGH);
toBinary(15);
for(size_t i = 0; i < size; i++ ){
digitalWrite(pins[i], digits[i]);
}
delay(3000);
digitalWrite(pin13, LOW);
}