When we look at the electronic items around us, you realize that they have many replaceable features and they are designed by engineers to be most useful to the user. Such as lighting systems, cooking systems, sound systems, cleaning systems. The way it works, the amount, the method, etc., by many system users. features can be programmed to change.
In robotic projects, in the processes of changing the sound level, changing the motor speed, changing the brightness of the light, the electrical voltage is sent in a way that creates a lower or higher effect. By decreasing the frequency of the electrical signal to the component, it can be operated at a lower level, and by increasing the frequency of the outgoing electrical signals, it can be operated at a higher level.
In systems without a screen, real-time graphic monitors are used to monitor some sensors and variables involved in the operation of the system. Graphic monitors make it very easy to detect the fault.
from machine import Pin,ADC,PWMfrom utime import sleep
#define libraries
led=PWM(Pin(7))
pot=ADC(Pin(26,Pin.IN))
#define the value we getfrom the led and pot.
led.freq(1000)while True:#while loop
led.duty_u16(int((pot.read_u16())))print(str(int((pot.read_u16()))))
#Turn on the LED according to the value from the potentiometer.sleep(0.1)#delay
Arduino C Codes of the PicoBricks
voidsetup(){// put your setup code here, to run once:pinMode(7,OUTPUT);//initialize digital pin 7 as an outputpinMode(26,INPUT);//initialize digital pin 26 as an input
Serial.begin(9600);//start serial communication}voidloop(){// put your main code here, to run repeatedly:
int pot_val =analogRead(26);
int led_val =map(pot_val,0,1023,0,255);digitalWrite(7, led_val);
Serial.println(led_val);//trun on the LED according to the value from the potentiometerdelay(100);//wait}
GitHub Project Page