Posts

Showing posts from 2016

How to fix Arduino Sketch upload issue with Arduino Pro Mini

Image
Used Items : Arduino Pro Mini Arduino Pro Mini  -  Ebay Link CP2102 USB 2.0 to TTL UART (Transistor–transistor logic) - Ebay Link Drivers for TTL (CP2120) Download Issue :  avrdude: stk500_recv(): programmer is not responding Issue when uploading Sketch into Arduino Device. How to resolve :  Press the reset button on the board immediately while it's start to change the text Compiling state in to Uploading . Fix the issue when uploading sketch into Arduino by pressing reset button on the Arduino Board.

Digispark Tiny85 Programing Tutorial

Image
Required items list: Tiny85 Board (working voltage of 1.8V to 5.5V.)  - Ebay $1.20 $ Drivers for Tiny85  -  Download here or here Micro USB cable. Arduino IDE - https://www.arduino.cc/en/Main/Software   You can compare the size with intel stiker. it's 8mm by 9mm Tiny85 from ebay - http://www.ebay.com/itm/191899183295 Specification: 8K Flash memory 6x Digital pins P0 - P5 (two shared for USB communication) 4x ADC pins (shared with digital pins) SPI interface (shared with digital pins) I2C interface (shared with digital pins) 3x PWM outputs (shared with digital pins) Can be powered via USB, 5V, or VIN (7-12V) inputs On board 5V 0.5A regulator for external supply Power LED and user controlled LED More info on ATtiny85 on Atmel - http://www.atmel.com/devices/attiny85.aspx?tab=parameters Datasheets of ATtiny25-ATtiny45-ATtiny85 - Download or Mirror 1.First of all download the relevant driver to program Tiny85 board. https://github.com/digistump/Digi

Multithreaded file writer in C++

Image
mul·ti·thread·ing   A technique by which a single set of code can be used by several processors at different stages of execution. The class lock_guard is a mutex wrapper that provides a convenient RAII-style mechanism for owning a mutex or several mutexes (since C++17) for the duration of a scoped block. When a lock_guard object is created, it attempts to take ownership of the mutex it is given. When control leaves the scope in which the lock_guard object was created, the lock_guard is destructed and the mutex is released. If several mutexes are given, deadlock avoidance algorithm is used as if by std::lock . (since C++17) The lock_guard class is non-copyable. #include "stdafx.h" #include <mutex> CWinApp theApp; using namespace std; const int size_ = 100; //thread array size std::mutex mymutex; void printRailLock(int id) {     printf("#ID :%d", id);     lock_guard<std::mutex> lk(mymutex); // <- this is the lock     CStdioFile lastLog;   

LPCSTR - L‌ong P‌ointer to a C‌onst T‌CHAR string

LPCTSTR = L ‌ong P ‌ointer to a C ‌onst T ‌CHAR STR ‌ing (Don't worry, a long pointer is the same as a pointer. There were two flavors of pointers under 16-bit windows.) Here's the table: LPSTR = char* LPCSTR = const char* LPWSTR = wchar_t* LPCWSTR = const wchar_t* LPTSTR = char* or wchar_t* depending on _UNICODE LPCTSTR = const char* or const wchar_t* depending on _UNICODE Source: MSDN

Why use hexadecimal values for computer ?

Let's look at the evolution of the human numbering systems : humans tried base 13, base 11, base 4, base 3, Oh man ! you name it ... until the Hindu-Arabic numbering system BASE 10 was invented. It made everything much easier, from business transactions to handling all sorts of daily interactions including numbers ... Because, we have 10 fingers :) -  Tolga Soyata · University of Rochester How about computers ? It is very clear where the BINARY numbering came from: BASE 2 is the natural representation for CPUs ... TRUE or FALSE, the most NOISE TOLERANT numbering system, which is necessary when you are working at 4GHz, and flipping billions of these BITS a second, and you do not want to mistake a 0 for 1. Any higher base system, Base 16 (i.e., hexadecimal), and BASE 256 (BYTE) is a natural expansion of BINARY by using MULTIPLE BINARY bits ...     Your question translates to : WHY DID WE INITIALLY CHOOSE TO GROUP 4-BITS ... In other words, why not 5 bits ? 5 bits would be much bet

First question post in StackOverflow and still alive it

When setting a form's opacity should I use a decimal or double? I want to use a track-bar to change a form's opacity. This is my code: decimal trans = trackBar1.Value / 5000; this.Opacity = trans; When I try to build it, I get this error:     Cannot implicitly convert type 'decimal' to 'double'. I tried making trans a double, but then the control doesn't work. This code has worked fine for me in VB.NET in the past. Answer An explicit cast to double isn't necessary. double trans = (double)trackBar1.Value / 5000.0; Identifying the constant as 5000.0 (or as 5000d) is sufficient: double trans = trackBar1.Value / 5000.0; double trans = trackBar1.Value / 5000d;  Url http://stackoverflow.com/questions/4/

Hide and Show Process in C# using pInvoke

using System; using System.Collections.Generic; using System.Diagnostics; using System.Runtime.InteropServices; using System.Windows.Forms; namespace TeamViwerHide {     public partial class frmProcessOp : Form     {         public frmProcessOp()         {             InitializeComponent();         }         [DllImport("User32")]         private static extern int ShowWindow(int hwnd, int nCmdShow);         private void frmProcessOp_Load(object sender, EventArgs e)         {             Process[] proc = Process.GetProcesses();             List<ComboboxItem> items = new List<ComboboxItem>();             foreach (Process p in proc)             {                               try                 {                                      ComboboxItem item = new ComboboxItem();                     item.Text = p.ProcessName + @"\" + p.Id + @"\" + p.SessionId;                     item.Value = p.MainWindowHandle;