Trying to write a custom library for a blinking light - arduino

I'm new to arduino and want to make some libraries. Full Disclosure: I am not a programmer and have been following some tutorials and reading as much as I can about rewriting functions as libraries. Yet, I still have some questions.
Example: I want to set up a custom blink pattern for the LEDpin on my arduino UNO. I want to include this blinking code on future projects and would like to use it with the #include statement when I start a new project. (easy?)
As an example:
The often referenced Morse Code Library tutorial here
I have the files saved in ..\My Documents\Arduino\libraries\Morse\morse\
there are 4 files:
keywords.txt
morse.c
morse.h
morse.ino
They exist in those files exactly as the final code examples on the linked page.
Question 1: can anyone verify if this tutorial is accurate for an
Arduino Uno using 1.6.4?
I can not get this or any "library" that I "create from scratch" to compile or upload to the mcu.
It doesn't seem to get any simpler than this in terms of a "custom library" tutorial. Would it help to post the error codes or PEBCAK?
Much of the style guide stuff was too advanced for me to follow but I did try to put the .c and .h files into a sub directory called \src. It didn't help.
I can't get rid of the ..\Morse\morse double directory. I am doing everything in arduino IDE and it makes it's own folders. If I move files around after I save it, it doesn't work when I reopen it and automatically resaves it where it was and I end up with all these weird duplicate files and folders.
Question 2: Do I need to be working in some other editor when creating a library?
Thanks!

The file in your folder should be:
Librairies/
Morse/
morse.cpp
morse.h
keywords.txt

Related

How do I include code snippets (not objects) in an Arduino program?

Problem Solved!!! See below for solution
I was about to post this question and decided to check the web one more time. This site https://www.freepascal.org/docs-html/prog/progsu40.html
has this statement: The {$I filename} or {$INCLUDE filename} directive tells the compiler to read further statements from the file filename. The statements read there will be inserted as if they occurred in the current file.
This is exactly what I want to do with Arduino. How do I do it?
My Skill Set:
Writing code since 1967. Yes, I survived Y2K, which was a real thing; so I'm not new to programming/debugging. Mainframes and PC's. Very solid COBOL and SAS skills. Good skills with Borland/Lazarus Object Pascal. Weak C/C++ skills.
Background:
I have two working Arduino programs that are used on a model railroad. Prog1 uses infrared sensors to light LEDs that indicate the position of a train in a tunnel. I built the IRSensor class to handle a single sensor. Prog2 uses push-buttons to set a route through several track switches. Each track switch is set via a servo. I extended the Servo class to TOServo, which encapsulate most of the commonality in each track switch.
Now I'm working on a different model railroad and need merge Prog1 and Prog2 into a single program. Building Prog3 via copy/paste from programs 1 & 2 has proved unwieldy.
Problem:
How do I tell the Arduino pre-processor/compiler to "insert filename here; do not compile, pre-compile, or otherwise process the filename unless it is wrapped around the file asking for the insertion"?
What I've tried:
I built Prog3 by separating the code for Prog2 into 3 sections -- Main program storage & code and 2 include statements (Storage definitions and executable code for TOServo). These include statements pull in code that define or access an array of TOServo. I've used several suffixes (.h/.ino and .h/.cpp and .c/.c), and they all generate 'not declared in this scope' errors.
Finally:
Thanks for your help.
SOLUTION
My .ino file had grown large & unwieldy. The 'solution' was to move a large segment of code and matching declarations to external .h/.cpp files, and to access those files via #include statements. The program would not compile (undefined variables); they were, in fact, defined but the compiler couldn't find them. After many attempts to fix or rearrange the code, finally two things dawned on me.
1)The Arduino pre-compiler changes (rearranges?) my code so that C++ and the Arduino CPU can work together. This means that the code I see is not always the code the compiler sees.
2)My .h/.cpp files define and manage an array of servo objects. I could convert those files into an object that I access from the main .ino file.
So I've solved my problem. Thanks to all those who have posted in many forums/sites, especially to Tarick Welling who stayed with me to the end.

How to rename the .mcs output file when synthesizing a design with Xilinx ISE

When I synthesize a design using Xilinx ISE, the output file is named untitled.mcs. I would like to configure the project to use an output filename more appropriate to the project I am synthesizing.
I have examined all the properties easily reachable by right clicking the the implementation panel in the tool, but I can't find a configuration option to change output file names. I have also searched the help, but couldn't find anything useful. Can anyone suggest where I need to configure the output filename or tell me where or what to search?
I am aware of at least two things I could be doing wrong and would appreciate comments. First, I am not using TCL to synthesize my project. I just right click in the implementation panel and choose run. Perhaps if I create a TCL script to I would have finer control or output file naming. Second, I can see several files named untitled.x where x is [cfi|mcs|prm|sig]. I guess these are a sequence of files processed from one format to another, and if I understood the process, I could configure the name of the first and see all the derived files change their names to follow.
The answer to my question is that you don't use ISE to configure output PROM file names, you do it in the iMPACT tool. When it is properly configured, ISE will run iMPACT to create the programming file.
If anyone needs the precise details on configuring iMPACT, the built in help has the details. See the section entitled "Creating Xilinx Flash/PROM Files". During the setup of the programming file, you get to choose the output file name.
One extra pointer from me: The help says you double click to open a wizard. For me that didn't work, but there is an icon (or tool bar button) to launch the PROM file formatter wizard when Create PROM File is highlighted in the iMPACT Flows panel.
When you have created an saved an iMPACT project file, you select it in ISE and ISE will create a PROM programming file at the last step of the synthesize process.

How to associate the file extension of an Arduino sketch file (.ino file) as a C/C++ file for syntax highlighting?

I'd like to use KDevelop as my editor. How do I tell KDevelop to treat the .ino files as C/C++ files so it does things like syntax highlights and "Jump to Declaration"?
Is there a place to associate file extensions?
I take it, you can edit Kate's syntax highlighting file for C++, and add .ino extension to extensions attribute of <language> entity. Let me know if that worked for you, so I'll upstream this.
And BTW, there is a work-in-progress KDevelop plugin for developing for embedded systems. You might find it interesting (if you aren't using it already).
Open SystemSettings, go to 'Applications -> File Associations', search for 'x-c++src', and add '*.ino' to the list of filename patterns.
Alternatively, edit /usr/share/mime/text/x-c++src.xml manually, which has the same effect.

JarOutputStream creating a 'bad' jar

http://pastebin.com/qrSCZw3y
I made that so I can create jars whenever I want by doing:
Builder jarBuilder = new Builder("jarname.jar");
jarBuilder.createNewFile();
But, whenever I do that, it creates a jar, and when I click on the jar, I get this message:
http://i.imgur.com/SvPZcZv.png
I want the generated jar to say something like "Hello world" or whatever I define.
Please help me, as I've searched all across the internet, but there were no video tutorials, and the documentations that I found online didn't help me much either.
Thank you,
I know how to create a .jar file, but I don't know how to make it have custom settings user defined from my jframe.

Arduino Due in Atmel Studio 6.1. without Visualmikro

I prefer the tutorial from http://www.engblaze.com/tutorial-using-atmel-studio-6-with-arduino-projects/ over Visualmikro because I love being able to jump inside the arduino functions and modify them without having to install any kind of plugin.
I tried compile my project following the tutorial but it won't work: "undefined reference to _sbrk". Which sounds like a really bad linker error to me?
I needed to adapt a few things because the tutorial was written for an older version of the IDE and is targeting AVRs and not SAMs:
GNU C++/Symbols
List item
F_CPU = 84000000L
ARDUINO=154
GNU C++/Directories
[...]\Arduino\hardware\arduino\sam\cores\arduino
[...]\Arduino\hardware\arduino\sam\variants\arduino_due_x (had to change this one)
[...]\Arduino\hardware\arduino\sam\system\libsam
ARM/GNU Linker/Libraries
libcoreDue.a (I added Due, to be able to identify the type of arduino)
libsam_sam3x8e_gcc_rel_a
as well as the paths to those two files.
Any idea what I could have missed?
Thank you so much!

Resources