Theory
એવો board જે એક જ કામ forever કરે છે
દરેક SmartHostel job ને computer જોઈએ એવું નથી. Battery room-node ને dead simple કામ કરવું છે: દર મિનિટે temperature વાંચવું, બહુ ગરમી હોય તો LED blink કરવી અને લગભગ no power વાપરવી જેથી cell એક વર્ષ ચાલે.
અહીં Raspberry Pi absurd overkill છે: LED blink કરવા માટે એક વર્ષ OS boot કરવું અને એક દિવસમાં batteries drain કરવી. યોગ્ય tool છે Arduino: આ computer જ નથી, પણ નાનું MICROCONTROLLER છે જે ONE simple program ને reliably અને power ના whisper પર ચલાવે છે. આ Pi નું opposite અને perfect complement છે.
Theory
Arduino, ઔપચારિક રીતે
Arduino એક open-source electronics platform છે (hardware AND software), જે microcontroller ની આસપાસ બનેલું છે (Arduino Uno માં ATmega328P chip હોય છે).
Defining fact: એમાં NO operating system છે. એ એક જ program ચલાવે છે, જેને sketch કહે છે, સીધું chip પર અને ફરીફરીને forever. Multitasking નહીં, files નહીં, Linux નહીં: બસ તમારો code, metal પર, real time માં.
આ simplicity જ તેનો purpose છે: sensing અને controlling ને easy, cheap, precise-in-timing અને extremely low-power બનાવવું. એ બહુ COMPUTE કરતું નથી; એ SENSE અને CONTROL સુંદર રીતે કરે છે.
Practical
દરેક sketch નો આકાર: setup એક વાર, loop forever
// Arduino sketch: no operating system, just this, on the chip.
int tempPin = A0; // analog input (built-in ADC reads it)
int ledPin = 13; // digital output
void setup() { // runs ONCE at power-on
pinMode(ledPin, OUTPUT);
}
void loop() { // runs FOREVER
int reading = analogRead(tempPin); // ADC: voltage -> number
if (reading > 600) { // too hot?
digitalWrite(ledPin, HIGH); // alert LED on
} else {
digitalWrite(ledPin, LOW);
}
delay(60000); // wait a minute, then loop again
}
Theory
setup અને loop: આખું model
દરેક Arduino sketch માં exactly 2 functions હોય છે અને એ જ mental model છે:
- setup() power-on પર એક વાર ચાલે છે: pins configure કરો, things શરૂ કરો
- loop() ત્યારબાદ forever ચાલે છે: endless sense-decide-act cycle
કોઈ main() નથી, OS પર return નથી, કારણ કે return કરવા માટે OS જ નથી: power ન જાય ત્યાં સુધી chip loop() repeat કરતો રહે છે. analogRead પણ નોંધો: Arduino માં built-in ADC છે (sensor lesson નો analog-to-digital converter), એટલે એ analog sensors ને સીધા વાંચે છે. Beginners માટે sensing માં એ બહુ ઉપયોગી છે.
Quiz
Arduino અને Raspberry Pi વચ્ચેનો defining difference શું છે?
- Arduino વધુ powerful છે અને heavier programs ચલાવે છે
- Arduino કોઈ OS વગર one sketch ચલાવતું microcontroller છે; Pi OS સાથેનું computer છે
- Arduino sensors read કરી શકતું નથી
- Arduino Windows operating system ચલાવે છે
Show the answer
Arduino કોઈ OS વગર one sketch ચલાવતું microcontroller છે; Pi OS સાથેનું computer છે
Arduino bare microcontroller છે: OS નહીં, chip પર one sketch (setup + loop). Pi Linux ચલાવતું full computer છે. OS-versus-no-OS split THE distinction છે અને બીજા differences (power, real-time, compute) નું root છે. Option A એને invert કરે છે: Arduino deliberately far LESS powerful છે. Option C ખોટું છે: built-in ADC સાથે sensors વાંચવું એ તેનું મુખ્ય કામ છે. Option D nonsense છે: એ કોઈ OS ચલાવતું જ નથી, Windows તો દૂરની વાત. Pair યાદ રાખો: Arduino = microcontroller, no OS; Pi = computer, with OS.
Think first
Battery room-node માટે Arduino કેમ?
Room-node ફક્ત temperature read કરે છે અને alert blink કરે છે, coin cell પર એક વર્ષ ચાલવાનું છે. Arduino ના 3 traits આપો જે એને યોગ્ય બનાવે છે અને દરેક trait સામે Pi શું wrong કરશે એ કહો. પછી tap કરો.
Show the answer
(1) Ultra-low power: Microcontroller microamps વાપરે છે અને readings વચ્ચે deep-sleep થઈ શકે છે: cell પર એક વર્ષ; Linux boot કરતો Pi એ cell ને કલાકોમાં drain કરી દે. (2) Real-time reliability: OS ન હોવાથી background processes, boot કે crash-to-desktop નથી: loop predictable રીતે forever ચાલે છે, set-and-forget sensor માટે ideal. (3) Simplicity and cost: Job trivial છે (read, compare, blink); Arduino એને cheaply match કરે છે જ્યારે Pi ની computer power waste થાય છે. આખા unit નો rule: board ને job સાથે match કરો: simple/low-power/real-time = Arduino; compute/OS/networking = Pi.
Watch out
Arduino slips
"Arduino OS ચલાવે છે": એ ચલાવતું નથી: chip પર one sketch, no operating system. આ defining trait છે.
Heavy compute expect કરવું: Face recognition કે databases નહીં: એ sense અને control કરે છે; heavy jobs Pi ના છે.
setup/loop ભૂલી જવું: Sketch model (setup once, loop forever) examinable છે; main() નથી.
Built-in ADC miss કરવું: Arduino analogRead દ્વારા analog sensors સીધા read કરે છે: નામ લેવા જેવો practical convenience.
Theory
બે boards, એક decision
હવે બંને boards સ્પષ્ટ છે: Pi, pins poke કરી શકતું computer; Arduino, barely computer જેવું pin-poker. Neither better છે: બંને અલગ jobs માટેના tools છે અને real projects ઘણી વાર BOTH વાપરે છે (cheap sensor nodes તરીકે Arduinos, Pi gateway ને report કરે છે). Unit નો final lesson contrast ને decision table બનાવે છે: Raspberry Pi અને Arduino નો difference અને પસંદગી કેવી રીતે કરવી.
Summary
Key takeaways
- Arduino એક open-source microcontroller platform છે (hardware + software), જેમ કે Uno નો ATmega328P.
- એમાં NO operating system છે: chip પર સીધું એક sketch forever ચાલે છે.
- Sketch = setup() (એક વાર ચાલે) + loop() (forever ચાલે): endless sense-decide-act cycle; main() નથી.
- Real-time sensing/control, precise timing અને very low power માં એ ઉત્તમ છે; તેમાં built-in ADC છે (
analogRead). - Heavy computing માટે નથી: databases કે image recognition નહીં, એ Pi ના jobs છે.
- Application areas: sensor prototypes, robotics, wearables, home-automation gadgets, data-logging અને education.
- Memory hook: Arduino = reliable નાનું brain જે almost no power પર એક કામ forever કરે છે.