Forum Topic

Arduino Programming and Device Development Thread

  • The proper way of dealing with this is using serial interrupt but that is very advance and probably requires you to read the microcontroller manual, instead of relying on Arduino libraries.


    Nabasa mo ba ang code sa libaries ng Arduino? It's open source. Arduino's Serial libraries already do this. It pulls data from the UART during an ISR and saves it to a buffer. Likewise, the transmit register is also feed from another buffer thru an ISR. The serial libraries allow you to read and write from the RX and TX buffers. The Arduino core libraries are a collaborative effort of many people. You cannot do a better job than that. Why reinvent the wheel?
  • The stream updates every 200ms. What I wanted to do is to save those values of Q and W, store them use them later (after 5seconds). I am thinking of using a for statement but I really don't know where to start.


    May carriage return (CR) ba at the end of each line? You will need that to detect one line of the stream of data. You save the line of character to a string buffer and once the CR character is detected, you parse the string to extract the data. Since it occurs every 200ms (0.2 sec) and you will delay 5 seconds before using the data, you have to store the data in buffer. That needs to be at least 25 elements long.

    -- edited by motion55 on Mar 17 2016, 12:57 PM
  • Here is where to begin:

    void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
    }

    #define LINE_LENGTH 81
    #define CR 13

    unsigned char line_buffer[LINE_LENGTH];

    int count = 0;

    void loop() {
    if (Serial.available())
    {
    char data = Serial.read();
    if (data==CR)
    {
    ParseLineData();
    }
    else
    {
    if (count<LINE_LENGTH-1)
    {
    line_buffer[count++] = data;
    }
    else
    {
    count = 0;
    }
    line_buffer[count] = 0; // add a string terminator
    }
    }
    }

    void ParseLineData()
    {

    }
  • Nabasa mo ba ang code sa libaries ng Arduino? It's open source. Arduino's Serial libraries already do this. It pulls data from the UART during an ISR and saves it to a buffer. Likewise, the transmit register is also feed from another buffer thru an ISR. The serial libraries allow you to read and write from the RX and TX buffers. The Arduino core libraries are a collaborative effort of many people. You cannot do a better job than that. Why reinvent the wheel?


    If the Arduino library is the be-all and end-all defacto, then there wouldn't be any market for commercial development platform like IAR and KEIL, don't you think? I'm not against the Arduino library, I started from it. But once you develop more advance applications, at some point the library is not enough and you have to get down and dirty with the controller datasheet. If you read my initial reply, you'll be surprise that your pseudo-code is basically the same as my program flow, only yours abstracted the interrupt part with the built in library. If all the program does is retrieve the two numbers, then maybe the Arduino libary is more than enough. But I don't see any downside into understanding how the library actually works. After all, you don't want to be waiting for someone to write an Arduino library for a new sensor/module/etc if you can write your own
  • ^^^I would like to remind you that this is an Arduino thread. The context of the question of mhelieza25 is for a reply using the Arduino IDE. I disagreed with your suggestion that a "proper way of dealing with this" within the context of using the Arduino IDE. Of course, if you are to use a different IDE, then you can create your own routines if libraries are not available. I do agree there are better IDEs out there. But that is out of the context of this thread and not relevant to mhelieza25's problem .

    I do agree with you that it won't hurt studying the how the library actually works. In fact, I always do that in case there is a dispute on the "proper way" to do it. In this case the built-in serial library is more than sufficient.
  • Ok ba ito for total newbie sa arduino? Although may background naman ako sa programming (C, Java and VB). <click here for link>

    Tsaka pwede ba sa bata ang arduino? Say 6 years old?
  • ^^^It looks a bit pricey for what you get. Try mo sa Olx.ph for better kits at a lower price. Try mo rin magtanong sa Facebook groups.

    Pag kasabay mo ang 6-years old as you do the examples, it might spark some interest. At that age, I doubt makakaya niya kahit turuan mo.
  • ^motion55
    Salamat sir. That was helpful.
  • try mo sa v sy electronics may fb sila.... meron sila mga arduino project kits more cheaper than lazada's offer... newbie lng ako sa arduino and binili ko sa kanila un project kit pack #3 for P1,700 lng.... similar ang contents nito sa link na binigay but it has more items at cheaper price than the lazada arduino kit you mentioned...
  • Hello po. First time posting.

    May itatanong lang po ako tungkol sa mga arduino clones (Arduino Uno r3). Gusto ko po kasi sanang gumawa ng arcade stick.
    Sa pagreresearch ko po, nahanap ko ung unojoy. Kailangan daw niya ng atmega16u2 na usb chip (??? di ko sure kung un ung tawag), pero madalas daw po na kapag clone ch340 ung ginagamit. At 'di gagana ang unojoy sa ch340.

    May way po ba para madistinguish 'yon na kailangan mo lang tingnan 'ung board? Kasi madalas po wala akong nababasa sa specs kung atmega16u2/ch340 ung gamit.

    Pero may mga nabasa rin akong mga post na mas maganda raw po gawin sa Arduino Leonardo kasi natively pwede siyang maging HID. Ganoon po ba lahat ng Leonardo maski ung mga clones nito?

    Salamat po. Pasensya na sa nobela.
  • Arduino Uno R3 true clones use Atmega16U2 for the USB to serial coverter. The cheaper clones use the CH340. You can tell if it has the atmega16U2 if it has a 2nd 6 pin ICSP connector as shown in the picture below.




    The Leonardo uses the atmega32U4 instead of the atmega328p on the Uno. Always verify this.
  • may single pc board or other version ng raspberry pi na may kasamang arduino rin?
  • Parang may nakita ako sa olx, not sure pero its called latte panda kung sa raspberry pi, wala kase may built in pins sya accessible via python
  • Mayroon akong LattePanda 2G RAM/32G Flash with Windows 10 pre-installed. I bought the version without license from DFRobot ($89). But it was already activated when I first booted it into Windows. It comes with an Arduino Leonardo compatible on board as co-processor. I loaded the Blinky sketch. The Leonardo runs right a way as soon as you power the board. However, the main Atom CPU needs to be switched ON manually through a side pushbutton.

    I can't recommend this yet. The board has poor heatsinking for the main Atom processor. The processor seems to throttle down with the simplest video playback causing stuttering. Pag sinama ang cost ng power supply, case and additional cooling, the price is more expensive than other Windows 10 boxes with similar specs.
  • Di ba pag yung screen ay smaller than 6" Libre na license ng windows os? Eh yung lattepanda di na kailAngan ng activation kase walang screen
  • Walang kinalaman sa screen size. May HDMI port ang LattePanda. Nakakabit sa 1080p 27" monitor ko.
  • Obsolete na yung 1080p, dapst 4k or 8k screen
  • Obsolete na yung 1080p, dapst 4k or 8k screen+


    This is irrelevant to the issue of licensing.

    Besides it's a matter of just your opinion. It is still valid for my use.

    -- edited by motion55 on Feb 05 2017, 02:40 PM
  • up for this thread.

    guys meron bang nglakas ng loob irewire ang Main Panel (Circuit Breaker) pra sa Home Automation using Arduino, Relays, Wifi/Lan and Sensors? Sana meron kahit project lang hehe. I'm really interested on trying it out. Thanks all for the Thread contribution specially our TS. God bless!
  • up again for this thread...

    for the Arduino enthusiasts, guys gang ilang shield kya ang kayang mailagay sa arduino? For a start different shield uses different baud rate (serial communication), di naman sya pwede separate ng setting at ilagay sa loop? and what if lumaki nrn ang coding sa loop section (nested if statement and so on..), will it affect the consistency ng mga shields like motion sensor, wifi shield and so on... thanks and hopefully someone replies...God bless
  • Paano po mag program ng isang demo unit ng smart elevator?
  • [img][img]patulong naman po, ako po ay gumawa ng application para mag monitor at mag manage ng aircon, ang software na ginamit ko ay arduino ide at c# at hardware naman ay: arduino uno, jumping wires, at 4 channel relay.

    ang problema ay: hindi madetect ng application kung on/off yung aircon, dapat pagopen ng app nadetect na niya kung ano yung state ng aircon either on or off siya.



    C# Source Codes

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Data.SqlClient;
    namespace Aircon_UI
    {

    public partial class Form1 : Form
    {

    bool off_ac1 = false;
    bool off_ac2 = false;
    bool off_ac3 = false;
    bool off_ac4 = false;
    string on1 = "Aircon 1 is ON, ";
    string on2 = "Aircon 2 is ON, ";
    string on3 = "Aircon 3 is ON, ";
    string on4 = "Aircon 2 is ON.";
    string off1 = "Aircon 1 is OFF, ";
    string off2 = "Aircon 2 is OFF, ";
    string off3 = "Aircon 3 is OFF, ";
    string off4 = "Aircon 4 is OFF.";
    public Form1()
    {
    InitializeComponent();

    }
    private void button1_Click(object sender, EventArgs e)

    {
    serialPort1.Open();

    MessageBox.Show("System started!");
    button1.Enabled = false;
    button2.Enabled = true;
    button3.Enabled = true;
    button4.Enabled = true;
    button6.Enabled = true;
    button7.Enabled = true;

    if (off_ac1)
    {
    button2.Text = "OFF";
    button2.BackColor = Color.Gray;
    off_ac1 = false;
    serialPort1.Write("1");
    textBox1.Text = off1;
    }
    else
    {
    button2.Text = "ON";
    button2.BackColor = Color.Yellow;
    off_ac1 = true;
    serialPort1.Write("0");
    textBox1.Text = on1;
    }
    }
    private void button3_Click(object sender, EventArgs e)
    {
    if (off_ac2)
    {
    button3.Text = "OFF";
    button3.BackColor = Color.Gray;
    off_ac2 = false;
    serialPort1.Write("2");
    textBox1.Text = off2;
    }
    else
    {
    button3.Text = "ON";
    button3.BackColor = Color.Yellow;
    off_ac2 = true;
    serialPort1.Write("3");
    textBox1.Text = on2;
    }
    }
    private void Form1_Load(object sender, EventArgs e)
    {
    if (button1.Enabled == true)
    {
    button2.Enabled = false;
    button3.Enabled = false;
    button4.Enabled = false;

    button6.Enabled = false;
    button7.Enabled = false;
    }
    }
    private void button5_Click(object sender, EventArgs e)
    {
    Application.Exit();
    serialPort1.Close();
    }
    private void textBox1_TextChanged(object sender, EventArgs e)
    {
    }
    private void button4_Click(object sender, EventArgs e)
    {

    if (off_ac1 == true && off_ac2 == true && off_ac3 == true && off_ac4 == true)
    {
    textBox1.Text = on1 + on2 + on3 + on4;
    }
    if (off_ac1 == false && off_ac2 == false && off_ac3 == false && off_ac4 == false)
    {
    textBox1.Text = off1 + off2 + off3 + off4;
    }
    if (off_ac1 == false && off_ac2 == true && off_ac3 == true && off_ac4 == true)
    {
    textBox1.Text = off1 + on2 + on3 + on4;
    }
    if (off_ac1 == false && off_ac2 == false && off_ac3 == true && off_ac4 == true)
    {
    textBox1.Text = off1 + off2 + on3 + on4;
    }
    if (off_ac1 == false && off_ac2 == false && off_ac3 == false && off_ac4 == true)
    {
    textBox1.Text = off1 + off2 + off3 + on4;
    }
    if (off_ac1 == true && off_ac2 == true && off_ac3 == true && off_ac4 == false)
    {
    textBox1.Text = on1 + on2 + on3 + off4;
    }
    if (off_ac1 == true && off_ac2 == true && off_ac3 == false && off_ac4 == false)
    {
    textBox1.Text = on1 + on2 + off3 + off4;
    }
    if (off_ac1 == true && off_ac2 == false && off_ac3 == false && off_ac4 == false)
    {
    textBox1.Text = on1 + off2 + off3 + off4;
    }
    if (off_ac1 == true && off_ac2 == false && off_ac3 == true && off_ac4 == false)
    {
    textBox1.Text = on1 + off2 + on3 + off4;
    }
    if (off_ac1 == false && off_ac2 == true && off_ac3 == false && off_ac4 == true)
    {
    textBox1.Text = off1 + on2 + off3 + on4;
    }
    if (off_ac1 == false && off_ac2 == true && off_ac3 == false && off_ac4 == false)
    {
    textBox1.Text = off1 + on2 + off3 + off4;
    }
    if (off_ac1 == false && off_ac2 == false && off_ac3 == true && off_ac4 == false)
    {
    textBox1.Text = off1 + off2 + on3 + off4;
    }
    if (off_ac1 == true && off_ac2 == false && off_ac3 == true && off_ac4 == true)
    {
    textBox1.Text = on1 + off2 + on3 + on4;
    }
    if (off_ac1 == true && off_ac2 == true && off_ac3 == false && off_ac4 == true)
    {
    textBox1.Text = on1 + on2 + off3 + on4;
    }
    if (off_ac1 == true && off_ac2 == false && off_ac3 == false && off_ac4 == true)
    {
    textBox1.Text = on1 + off2 + off3 + on4;
    }
    if (off_ac1 == false && off_ac2 == true && off_ac3 == true && off_ac4 == false)
    {
    textBox1.Text = off1 + on2 + on3 + off4;
    }
    }
    private void button2_Click_1(object sender, EventArgs e)
    {
    if (off_ac1)
    {
    button2.Text = "OFF";
    button2.BackColor = Color.Gray;
    off_ac1 = false;
    serialPort1.Write("1");
    textBox1.Text = off1;
    }
    else
    {
    button2.Text = "ON";
    button2.BackColor = Color.Yellow;
    off_ac1 = true;
    serialPort1.Write("0");
    textBox1.Text = on1;
    }

    }

    private void button6_Click(object sender, EventArgs e)
    {
    if (off_ac3)
    {
    button6.Text = "OFF";
    button6.BackColor = Color.Gray;
    off_ac3 = false;
    serialPort1.Write("4");
    textBox1.Text = off3;
    }
    else
    {
    button6.Text = "ON";
    button6.BackColor = Color.Yellow;
    off_ac3 = true;
    serialPort1.Write("5");
    textBox1.Text = on3;
    }
    }

    private void button7_Click(object sender, EventArgs e)
    {
    if (off_ac4)
    {
    button7.Text = "OFF";
    button7.BackColor = Color.Gray;
    off_ac4 = false;
    serialPort1.Write("6");
    textBox1.Text = off4;
    }
    else
    {
    button7.Text = "ON";
    button7.BackColor = Color.Yellow;
    off_ac4 = true;
    serialPort1.Write("7");
    textBox1.Text = on4;
    }
    }

    private void groupBox2_Enter(object sender, EventArgs e)
    {

    }

    private void groupBox3_Enter(object sender, EventArgs e)
    {

    }

    private void serialPort1_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
    {
    }
    }
    }


    Arduino Source Codes
    char incomingOption;
    void setup() {
    pinMode(13,OUTPUT);
    pinMode(12,OUTPUT);
    pinMode(11,OUTPUT);
    pinMode(10,OUTPUT);
    Serial.begin(9600);
    }
    void loop() {

    incomingOption = Serial.read();
    if (incomingOption ='1')
    {
    digitalWrite(13,HIGH);
    }
    else if (incomingOption ='0')
    {
    digitalWrite(13,LOW);
    }
    if (incomingOption='2')
    {
    digitalWrite(12,HIGH);
    }
    else if (incomingOption='3')
    {
    digitalWrite(12,LOW);
    }
    if (incomingOption='4')
    {
    digitalWrite(11,HIGH);
    }
    else if (incomingOption='5')
    {
    digitalWrite(11,LOW);
    }
    if (incomingOption='6')
    {
    digitalWrite(10,HIGH);
    }
    else if (incomingOption='7')
    {
    digitalWrite(10,LOW);

    }
    }
  • ang problema ay: hindi madetect ng application kung on/off yung aircon, dapat pagopen ng app nadetect na niya kung ano yung state ng aircon either on or off siya.


    kung gamit mo lang ay relay at gusto mo pgopen ng app eh madedetect na nya...it's not possible. unless, ggmitan mo ng additional module pra me read state ka pra malaman kung alin ang active.

    advise ko is run your application, let your relay do the control and then base this on your aircon on/off state. just let your app run continuously.
  • kung gamit mo lang ay relay at gusto mo pgopen ng app eh madedetect na nya...it's not possible. unless, ggmitan mo ng additional module pra me read state ka pra malaman kung alin ang active.

    advise ko is run your application, let your relay do the control and then base this on your aircon on/off state. just let your app run continuously.


    may alam kabang module na madedetect nya yung relay sir?
  • tanong ko lang is, need mo ba patayin ung arduino hardware mo? kasi kung 1st time mo irun yan, let's say nkaset sa off lahat ng relay mo (off din aircon) then run mo na ung arduino from there matratrack mna ung on/off ng aircon mo base nrin sa pgcontrol mo ng relay. wag mo nga lang iooff ung arduino, kasi kapag ioff mo depende sa set mo ng relay ehhh mamatay din lahat ng aircon na kinocontrol mo.. pm nlng kung di parin mkuha...
  • hindi na need po patayin yung arduino hardware kasi monitoring sya. sa first run ko sir nakadefault yung relay meaning ON sya lahat (yung aircon din), at pag OFF ko ng isang relay/aircon for example at inexit ko yung app (pero hindi nakapatay ang arduino hardware) , sa second run ng app, balik nanaman sa default yung state ng relay, hindi naka OFF yung isang relay/aircon

    sir contact nalang tayo sa fb, need ko talaga tulong mo
  • i think may standard protocol sa home automation, bili ka nun tapos ilagay mo sa aircon or whatever appliance you have kung hindi pa naka adapt sa ganung commynication system. i think may ganyan na project si msrk zuckerburg last year jervis tswag nya
  • heto pala yung sa screen size in relation to Microsoft windows license, nakita ko sa indiegogo:
    Due to Microsoft license policy,  any device with a touch-screen below 9" can have a free license for Windows 10 and Office. 

    dapat touch screen.
    kagaya nito:


    <click here for link>

    -- edited by minereth on Jun 22 2018, 10:08 AM
  • hi guys! ask lang kung meron kayong projects using led/lcd phone screens, para marepurpose ko yung phone screen ng lumang phone. Thanks!
  • Mga sir, question lang po. Possible po ba makakuha ng data from this setup?:

    1x HC-SR04 Ultrasonic Sensor
    1x HC-05 Bluetooth
    1x Arduino Uno R3

    Yung balak ko po kasi, magdidisplay po siya ng data from the sensor to Arduino's Command Line to Android app, possible po ba? Thanks.