0% found this document useful (0 votes)
3 views5 pages

Arduino & Raspberry Pi Coding Guide

The document provides a coding reviewer for Arduino and Raspberry Pi, outlining basic structures, essential commands, common patterns, and typical logic flows for both platforms. It highlights the differences between Arduino (C/C++, real-time, analog input) and Raspberry Pi (Python, requires ADC, not real-time). Additionally, it includes coding templates and key points to remember for effective programming in both environments.

Uploaded by

jasminecarmona64
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Arduino & Raspberry Pi Coding Guide

The document provides a coding reviewer for Arduino and Raspberry Pi, outlining basic structures, essential commands, common patterns, and typical logic flows for both platforms. It highlights the differences between Arduino (C/C++, real-time, analog input) and Raspberry Pi (Python, requires ADC, not real-time). Additionally, it includes coding templates and key points to remember for effective programming in both environments.

Uploaded by

jasminecarmona64
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CODING REVIEWER (Arduino + Raspberry Pi)

I. ARDUINO CODING REVIEWER

1. Basic Arduino Program Structure

- setup(): runs once, pin setup.

- loop(): runs repeatedly, main logic.

2. Essential Arduino Commands

Pin Configuration:

- pinMode(pin, INPUT)

- pinMode(pin, INPUT_PULLUP)

- pinMode(pin, OUTPUT)

Reading Inputs:

- digitalRead(pin)

- analogRead(pin)

Outputs:

- digitalWrite(pin, HIGH/LOW)

- analogWrite(pin, value)

Serial:

- [Link]()

- [Link](), println()
3. Common Arduino Patterns

- Reading button

- Reading analog sensor

- Using thresholds

- Mapping values

4. Typical Logic Flow

Input → Process → Output

II. RASPBERRY PI (Python) CODING REVIEWER

1. Setup

import [Link] as GPIO

import time

[Link]([Link])

[Link](pin, [Link]/OUT)

2. Input & Output

- [Link](pin)

- [Link](pin, True/False)

3. Time use

- [Link]()

4. ADC via SPI (spidev)


- Used for analog sensors

5. Ultrasonic Timing Logic

- Trigger pulse

- Measure echo time

- Convert to distance

III. Arduino vs Raspberry Pi

Arduino:

- C/C++

- Has analog input

- Real-time

Raspberry Pi:

- Python

- Needs ADC

- Not real-time

IV. Coding Templates

Arduino Template:

void setup() {

pinMode(2, INPUT);

pinMode(3, OUTPUT);
[Link](9600);

void loop() {

int val = analogRead(A0);

if (val > 500) digitalWrite(3, HIGH);

else digitalWrite(3, LOW);

Raspberry Pi Template:

import [Link] as GPIO

import time

[Link]([Link])

[Link](2, [Link])

[Link](3, [Link])

while True:

value = [Link](2)

if value == 1: [Link](3, True)

else: [Link](3, False)

[Link](0.1)

V. What to Remember

- Arduino analogRead = 0–1023


- Pi requires ADC

- Threshold logic is common

- Input → Processing → Output

You might also like