{"comment":{"url":"https://api.github.com/repos/trungmanhhuynh/Arduino-mini-pro-Bluetooth/comments/12355724","html_url":"https://github.com/trungmanhhuynh/Arduino-mini-pro-Bluetooth/commit/e7fbcdff27170cffd55a1390785faa70be9d2452#commitcomment-12355724","id":12355724,"user":{"login":"trungmanhhuynh","id":13492723,"avatar_url":"https://avatars.githubusercontent.com/u/13492723?v=3","gravatar_id":"","url":"https://api.github.com/users/trungmanhhuynh","html_url":"https://github.com/trungmanhhuynh","followers_url":"https://api.github.com/users/trungmanhhuynh/followers","following_url":"https://api.github.com/users/trungmanhhuynh/following{/other_user}","gists_url":"https://api.github.com/users/trungmanhhuynh/gists{/gist_id}","starred_url":"https://api.github.com/users/trungmanhhuynh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/trungmanhhuynh/subscriptions","organizations_url":"https://api.github.com/users/trungmanhhuynh/orgs","repos_url":"https://api.github.com/users/trungmanhhuynh/repos","events_url":"https://api.github.com/users/trungmanhhuynh/events{/privacy}","received_events_url":"https://api.github.com/users/trungmanhhuynh/received_events","type":"User","site_admin":false},"position":null,"line":null,"path":"","commit_id":"e7fbcdff27170cffd55a1390785faa70be9d2452","created_at":"2015-07-25T05:34:54Z","updated_at":"2015-07-25T05:34:54Z","body":"\r\n// Author : Manh Huynh . MNS LAB \r\n// This is the module to send a block of signal to pc through bluetooth \r\n// for Arduino Mini Pro 3.3V 8MHz \r\n// SoftwareSerial library must be installed first. \r\n// SoftwareSerial support to RX/TX at multi channels, means that we dont need to \r\n// plug out COM port with PC. \r\n// BUT FOR SURE, we plug them out and use RX/TX for transmission. ( can be used \r\n// by other pins. \r\n// This version improve the sampling rate of ananlog Read, The maximum is 100kHz by setting prescaler to 2. \r\n// The formula for this is  8Mhz/2/13 (prescaler is 2, ADC needs 13 clocks for one conversion) =  300 //kHz, we need to consider the number of clock cycles for writing in SRAM, and calculate other //instructions. Thus, the actual sampling rate must be slower. \r\n\r\n#include <SoftwareSerial.h>\r\nconst int RXpin = 0;                 // Read pin of Arduino \r\nconst int TXpin = 1;                 // Transmit pin of Arduino \r\nSoftwareSerial myPort(RXpin, TXpin);\r\n\r\nconst unsigned char PS_2  = (0 << ADPS2) | (0 << ADPS1) | (0 << ADPS0);\r\nconst unsigned char PS_4  = (1 << ADPS1) ;\r\nconst unsigned char PS_8  = (1 << ADPS1) | (1 << ADPS0);\r\nconst unsigned char PS_16 = (1 << ADPS2);\r\nconst unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0);\r\nconst unsigned char PS_64 = (1 << ADPS2) | (1 << ADPS1);\r\nconst unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);\r\n\r\nint value[700] ;\r\nvoid setup()\r\n{\r\nmyPort.begin(9600);\r\nADCSRA &= ~PS_128;  // remove bits set by Arduino library\r\n\r\n  // you can choose a prescaler from above.\r\n  // PS_16, PS_32, PS_64 or PS_128\r\n  ADCSRA |= PS_8;    // set our own prescaler to 64\r\n}\r\nvoid loop()\r\n{\r\nint start = millis(); \r\nint i ; \r\nfor(i = 0 ; i <700; i++){\r\n   value[i] = analogRead(A0);\r\n}\r\nint stoptime = millis(); \r\nint duration = stoptime - start ;\r\n\r\nfor(i = 0 ; i < 700; i++){\r\n  myPort.println(value[i]);\r\n}\r\n//myPort.print(\"time = --------------------\" );  \r\n//myPort.println(duration);\r\n}"}}